Passwordless ssh or scp using ssh-keygen & ssh-copy-id

Machine-1 to Machine-2


[oracle@machine-1 ~]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/oracle/.ssh/id_rsa.
Your public key has been saved in /home/oracle/.ssh/
The key fingerprint is:
The key's randomart image is:
+--[ RSA 2048]----+
|o.+.E.o*+.       |
|+o.+..o+++       |
|.=  +.  *.       |
|. o.     o       |
|        S        |
|                 |
|                 |
|                 |
|                 |
[oracle@machine-1 ~]$ ssh-copy-id -i ~/.ssh/ machine-2
oracle@machine-2's password:
Now try logging into the machine, with "ssh 'machine-2'", and check in:


to make sure we haven't added extra keys that you weren't expecting.

[oracle@machine-1 ~]$ ssh machine-2
Last login: Wed Dec  7 07:32:47 2016 from
[oracle@machine-2 ~]$ exit
Connection to machine-2 closed.
[oracle@machine-1 ~]$

Machine-2 to Machine-1

Repeat above steps from Machine-2


***** Offcourse this will only work if there is no firewall blocking connection on port 22 between Machine-1 & Machine-2