I have to install Ubuntu for my work and personal experiment several times a week. After every installation, I have to go through and configure some basic steps again and again. So, I have decided to put those things in a post so that I can recall them easily.
Before making any changes and installation, I run the update and upgrade command to get the latest packages with the below command.
sudo apt update sudo apt upgrade
1. Change root user password
At first, I change the password for the root user. Normally, there is no password for the root user. I set a strong password for the root user. Follow the below command for setting/changing the root user password in ubuntu.
sudo passwd root
Now Check the password by following command.
2. Install SSH
Next, I install SSH for easier access. If you are using the latest Ubuntu versions then you can install it during OS installation. If you skip that part, then you need to manually install it.
sudo apt install openssh-server
Check if the ssh service is running.
systemctl status ssh
3. Enable root login over SSH
By default root login over ssh is not allowed. If you want to enable root login over ssh follow the below command. Open /etc/ssh/sshd_config file with your favorite editor(I prefer nano).
Scroll down to Authentication and change PermitRootLogin to yes. Make sure to remove the # from the line.
If you are using nano then press Ctrl+X and then Y to save and exit. Restart the SSH service.
systemctl restart ssh
Now you will be able to login to root account directly over SSH.