How to setup SSH login without password on Linux systems — The Linux GURUS
We might be required to setup ssh login without password for any number of reasons like remote file/commands execution, initiating backups with SCP, etc. In this tutorial, we will learn to setup ssh login without password by using ssh public-private key-based authentication.
For this to work, we will first have to create ssh keys on one server, named SERVER A & then will copy the created public key to another Linux server, named SERVER B. The public key is copied into the file located in a user’s ssh directory i.e. ‘/home/user/.ssh/authorized_keys’.
Recommended Read: Simple guide to install POSTGRESQL on Centos/RHEL Also Read: Simple guide to install POSTGRESQL on Ubuntu
Let’s discuss the process to create password less ssh authentication,
Setup ssh login without password
1- Login to SERVER A, and then run the following command to create ssh keys,
Generating public/private rsa key pair. Enter file in which to save the key (/home/user/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/user/.ssh/id_rsa. Your public key has been saved in /home/user/.ssh/id_rsa.pub. The key fingerprint is:
As mentioned above two files named ‘id_rsa’ & ‘id_rsa.pub’ will be created in ‘/home/user/.ssh’ directory. We need to copy the public key ‘id_rsa.pub’ to SERVER B.
2- You can use two methods to copy the public key to SERVER B, either
$ cat ~/.ssh/id_rsa.pub | ssh [email protected](SERVER B) “cat >> ~/.ssh/authorized_keys”
$ ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected](SERVER B)
That’s it, we have now setup ssh login without password, but before we test it out we must make sure the permissions to files and folders are correct, i.e.
3- Next, we can setup ssh login without password,
We can now access the SERVER B from SERVER A without it asking for password. We now end this tutorial, please feel free to send in any questions or queries using the comment box below.
If you think we have helped you or just want to support us, please consider these:-
Linux TechLab is thankful for your continued support.
Originally published at https://thelinuxgurus.com on December 28, 2019.