How to Setup SSH Keys on Linux for Passwordless Login Easy Steps
For remote access to Linux servers, SSH ( Secure Shell ) is widely used. When we use ssh to connect to a remote system, it asks for our password and then just allows us to connect to the server. After sshing into a remote system, we will need to customize applications or scripts (mostly shell scripts) to automate activities.
However, if key-based ssh is not configured, a script will prompt for a password on each run, which we must manually enter. We have an alternative to using the
public/private key concept to solve this issue. On the basis of a key, the remote server allows other systems to ssh.
This guide will show you How to set up SSH Keys on Linux for Passwordless Login. In Linux systems using an ssh key pair, we can also call it password-less ssh.
Step 1: Generate an SSH key pair
To begin, you will need to generate a key pair
(RSA or DSA), which you can do by using the ‘
-t’ command line switch to specify the option
dsa key. If the
-t parameter is omitted, an
rsa key will be produced by default.
- ~/.ssh/id_rsa [private key]
- ~/.ssh/id_rsa.pub [public key]
Step 2: Copy the Public Key to the Remote System
Let us copy our system’s public key to the
/.ssh/authorized keys key file on remote systems. This can be done manually or with the help of the
ssh-copy-id command-line tool.
ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.10.20 Output Example:
It will ask you for the remote system’s password. Type the password for the remote machine and press Enter.
Step 3 – SSH without Password Verification
Now, as we have done before, try
sshing into the remote system. You can access the remote system without having to type a password.
The password would not be used to log in with the command above. In any case, if the ssh command asks for a password, the setup is not configured properly, and you can repeat all of the steps.
You learned how to generate an SSH key pair and set up key-based authentication between two systems in this tutorial. It is a password-less login for Linux systems.
Fix Wireless Keyboard not Working After Battery Replacement
Is there anything more frustrating than replacing the batteries in your wireless keyboard, only to find that it’s still not…