SSH login without password in Linux

For many reasons we need to access remote server automatically without providing password. Specially when you need to copy file through script or programming from one server to another server. We know that SSH is a secure protocol to access remote server. Here we will show how we can access remote server without providing password.  We have two servers: cgvm01 and cgvm02 ; and we will automatically login from cgvm01 to cgvm02.

[root@cgvm02 ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:

When you will be asked to enter passpharase keep it blank.

[root@cgvm02 ~]# ssh-copy-id root@cgvm01
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed — if you are prompted now it is to install the new keys
root@cgvm01’s password:

Number of key(s) added: 1

Now try logging into the machine, with: “ssh ‘root@cgvm01′”
and check to make sure that only the key(s) you wanted were added.

Here cgvm01 is the remote host.  You need to provide its password against the provided user.

Step 3: login to remote host

[root@cgvm01 cluster]# ssh root@cgvm02
Last login: Tue Sep 20 15:38:42 2016 from 192.168.8.82

You don’t need to provide password any more.

 

One thought on “SSH login without password in Linux

Comments are closed.