Passwordless SSH login is a convenient and secure way to access your remote Linux servers without having to type in your password every time you log in. It involves setting up public-key authentication between the client and server, which eliminates the need for a password.

Advertisement

In this article, we will walk you through the steps to set up passwordless SSH login on Linux. We will cover how to generate an SSH key pair, copy the public key to the remote server, and test the passwordless login. We will also provide troubleshooting tips to help you overcome common issues that may arise when setting up passwordless SSH login.

  • How to Change the SSH Port in Linux
  • By following the steps in this article, you can enhance the security and convenience of accessing your remote Linux servers.

    Step 1: Generate SSH Key Pair

    The first step is to generate a public and private key pair on your local machine. To generate an SSH key pair, run the following command in the terminal:

    ssh-keygen 
    

    You will be prompted to enter a filename and a passphrase. The default filename is “id_rsa” and the default location is “~/.ssh/”. You can accept the defaults by pressing enter.

    Output
    Generating public/private rsa key pair. Enter file in which to save the key (/home/rahul/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/rahul/.ssh/id_rsa Your public key has been saved in /home/rahul/.ssh/id_rsa.pub The key fingerprint is: SHA256:bNZypK3akmqpJlotvdoD3OPZ/TmhnwdL76v9Uxvz1AY rahul@tecadmin The key's randomart image is: +---[RSA 3072]----+ | | | | | . | | . = E | | . . S + ..| | ooo o ++ o=| | ooo= o.o = +=| |...o*.+oo o+o ...| |ooo++o...o*=+o.. | +----[SHA256]-----+

    Step 2: Copy the Public Key to the Server

    Once you have generated the key pair, you need to copy the public key to the remote server. You can do this using the “ssh-copy-id” command, which is included in most Linux distributions.

    ssh-copy-id username@remote-host 
    

    Replace “username” with your username on the remote server and “remote-host” with the IP address or hostname of the remote server.

    The “ssh-copy-id” command will prompt you for the password of the remote user account. Enter the password to copy the public key to the remote server.

    Step 3: Test the Passwordless Login

    Now that you have copied the public key to the remote server, you can test the passwordless login by running the ssh command:

    ssh username@remote-host 
    

    Replace “username” with your username on the remote server and “remote-host” with the IP address or hostname of the remote server.

    If everything is configured correctly, you should be logged in to the remote server without being prompted for a password.

    Troubleshooting Tips

    If the passwordless login does not work, check the following:

    • Make sure the public key is copied to the correct location on the remote server. The public key should be located in the “~/.ssh/authorized_keys” file of the remote user’s home directory.
    • Make sure the permissions on the “~/.ssh/” directory and “~/.ssh/authorized_keys” file are set correctly. The directory should have permissions of 700 and the file should have permissions of 600.
    • Make sure the SSH server on the remote server is configured to allow public-key authentication. Check the “sshd_config” file in the “/etc/ssh/” directory and make sure the “PubkeyAuthentication” option is set to yes.

    Conclusion

    Setting up passwordless SSH login on Linux is a simple and secure way to access your remote servers. By using public-key authentication, you can eliminate the need to type in your password every time you log in to a remote server. Follow the steps outlined in this article to set up passwordless SSH login and enjoy the convenience and security it provides.

    Share.

    1 Comment

    Leave A Reply


    Exit mobile version