How to Configure Passwordless SSH Login in Linux

You can avoid entering a password every time you SSH into a Linux machine by configuring RSA keys. This is actually more secure than using a password and is obviously a lot more convenient. Just follow these few quick steps to get it set up.

Generating RSA Keys for SSH Without Password

1. On the client machine (the one you are SSHing from), open a terminal and generate RSA keys with the following command:

ssh-keygen -t rsa

2. Press enter three times and your RSA keys will be generated and stored in your user’s ~/.ssh directory.

SSH RSA key generation with the ssh-keygen command

3. Next, copy the public RSA key over to the server you want to login to. You’ll have to enter your password for this, but it will be the last time.

ssh-copy-id -i ~/.ssh/ username@hostname

In the above command, be sure to replace “username” with the account you login with and “hostname” with either the hostname or IP address of the server you’re connecting to.

Copying SSH keys to remote host with ssh-copy-id command

You should get a response like “Number of key(s) added: 1”

4. Try an SSH connection to the server like usual. You shouldn’t be prompted for a password anymore.

Successful login using SSH keys and no password

Leave a Reply

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