Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Network Services»SSH»How to Set Up Passwordless SSH Login on Linux

    How to Set Up Passwordless SSH Login on Linux

    By RahulFebruary 24, 20234 Mins Read

    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 [email protected] 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 [email protected] 
    

    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 [email protected] 
    

    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.

    authentication Passwordless SSH
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    How To Display Warning Message to Unauthorized SSH Access

    How to Set a Custom SSH Login Banner and MOTD

    How to Install and Secure OpenSSH Server on Pop!_OS

    View 1 Comment

    1 Comment

    1. Ezeelogin on June 10, 2022 10:14 am

      Thanks a Lot!!! very nice tip!

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to List Manually Installed Packages in Ubuntu & Debian
    • 10 Bash Tricks Every Developer Should Know
    • How to Validate Email Address in JavaScript
    • Firewalld: Common Firewall Rules and Commands
    • 12 Apk Commands in Alpine Linux Package Management
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.