Welcome to another tutorial,
Today we will discuss on how to login onto an ubuntu/debian machine without a password authentication, we will be using a key generated to authenticate and login.
First of all, we are imagining you have two separate installation of debian/ubuntu servers
login onto the two machines on separate windows, so that we can see what is happening on both side and testing purposes.
We will be using a root account to login onto the server so that we can have full access and no need of switching from different users
login onto one of your machine, upon successfull login run the command below to generate a key
after pressing enter, you will be asked to put a name for the new key to be stored, just leave empty and it will generate a file called id_rsa.pub and the key will be stored there
Next it will ask you to put a password, dont put a password just leave it empty as we will be using passwordless login
on all the steps following screen will show from start to end
After you have genetated the key
you will see three files
Now we need to transfer the key genetated to the remote server, so that it can allow us to login without using a password.
use the command below to copy the content of the file id_rsa.pub to the remote server
# ssh-copy-id username@remote_host_name
Enter the password of the remote username and the content will be copied to a file called authorized_keys
View the content of the authorized_keys on the remote server to confirm that the key is copied.
now your ready to login onto the remote server without a password, but before that please reload the ssh daemon to activate the changes you have made
# /etc/init.d/ssh restart
Now test login
# ssh root@remote-host-name
you should be logged in successfully without prompted for a password
Thanks and have a good day