How to ssh without password

Dear Linux Yogi’s,

as a Linux System Administrator it can be very tedious to log in and enter password each time it you have to manage a bunch of Linux Servers. So in order to save some time and also to enhance the security I am going to show you how to set up ssh login without password.Follow along!

First of all make sure you systems are up to date by running

sudo apt-get update

and then

sudo apt-get upgrade

and in some cases you need to run

sudo apt-get dist-upgrade

if some packages are held back. So this should get you to a up2date state. Now the next step is generating a strong RSA key for our ssh connection. Run the following command:

ssh-keygen command
ssh-keygen command

So what does this command actually do. This command create a key pair and the command line switch -t rsa instructs the command to generate a RSA 2 key and the command line switch -b 2048 instructs the command to generate a 2048 bit key. With ssh-keygen you can create encryption keys for

  • rsa1
  • rsa (this is by default version 2)
  • dsa
  • ecdsa
  • ed25519

and by default the bit a key is generated is 2048 but I added it there so I can show you that you can change that if desired. The minimum is 768 bit and I believe the maximum is 4098. Over all 2048 bit is considered sufficient. If you like to know more about this command and it’s option run man ssh-keygen and it provides you with a list of options and explanations.

After we issued the command you will see the following:

generating ssh key pair
generating ssh key pair

this means it is creating the key pair of id_rsa and id_rsa.pub and next it asks you if you like to use a passphrase. I usually don’t use one but if you like higher security I encourage you to use a passphrase but you will be required to enter this password instead. So leave it empty for now so we can connect via ssh without password.

providing passphrase
providing passphrase

Go ahead and press enter here to confirm that you really don’t want a passphrase.

confirm passphrase
confirm passphrase

Finally the command is generating our RSA Version 2 key pair with 2048 bit.

generating the rsa key
generating the rsa key

Now we have to upload this key to our desired server(s). Issue the following command:

transfer new key to server
transfer new key to server

The command ssh-copy-id will use the public id_rsa.pub key and uploads it to the user account on the remote server you like to connect to. In my case it is the user id itmgr and the server with the IP 192.168.14.253. You have to enter one last time your password for this task and after this is successfully done you are no longer required to enter a password from this machine.

ssh key successfully transferred
ssh key successfully transferred

As you can see in the screenshot the upload was successful and it even tells you how to log in to this machine without password.

successful ssh login without password
successful ssh login without password

As you can see there was no password prompt. I hope you find this article useful. If you do please register and leave a comment.

Than you for reading and Namaste my friends 😉