No password SSH – Login to a SSH server with private/public keys

If you often need to establish SSH connections to a server, entering the password each time may be a hassle or even a non-starter. For example, in our case, we use ssh connections in our nightly build scripts, so obviously entering a password would not be an option here…

So it can be useful to configure the server and your client to accept secure ssh connection without the need to enter a password.  What must be done, then, is to generate a public/private key pair, and copy the public part into the appropriate place on the server side.

For doing this, on the user’s home directory, on the client machine, type:

-t tells the type of encryption
-f tells where to store the public/private key pairs. In this case, the .ssh directory in the home directory is being used

A password will be asked;  leave this part blank, just press <enter>
Now, go to the .ssh directory, and you will find two new files: id_rsa and The last one is the public part. Now, copy the public key to the server machine:

Of course, this time you will need to enter the password. Now, login into the server machine and go to the .ssh directory on the server side:

Then add the client’s public key to the known public keys on the server:

and that’s all. Next time you log into the remote server, no password will be asked. If that does not work, you can try to use authorized_keys instead of authorized_keys2, since it may depend on the Linux version used.

Note that this system will work while none of the machines change its IP address and for the specific user, so it is still safe.

Reference: (Link is down now)

[Updated: Initially written in February 2010, but updated in September 2020 to replace DSA with RSA, as the DSA keys were deprecated by OpenSSH].

Share this:
FacebookTwitterHacker NewsSlashdotRedditLinkedInPinterestFlipboardMeWeLineEmailShare

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK 5 ITX RK3588 mini-ITX motherboard

One Reply to “No password SSH – Login to a SSH server with private/public keys”

Leave a Reply

Your email address will not be published. Required fields are marked *

Khadas VIM4 SBC
Khadas VIM4 SBC