Friday 24 May 2013

How to scp, ssh and rsync without prompting for password


For example, login in to some host linux box as root 172.16.0.155 and pass the command as,

ssh-keygen -t rsa

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:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
35:50:28:70:2b:b0:9f:01:9a:8b:cb:0e:17:89:1d:a2 root@InVImFTSrv
The key's randomart image is:
+--[ RSA 2048]----+
|  o ... .o.      |
| o + .....       |
|+ o o ..  o      |
|o= + +   . .     |
|E + o   S        |
|.. .             |
|o..              |
|o.               |
| .               |
+-----------------+


now login to the host linux box as root 172.16.0.177 and copy,

scp -r root@172.16.0.155:/root/.ssh/id_rsa.pub /root/.ssh/

cd /root/.ssh/
cat id_rsa.pub >> authorized_keys
chmod 700 /root/.ssh/authorized_keys

now form 172.16.0.155 try ssh, scp or rsync as,

scp -r root@172.16.0.177:/usr/local/src/April /usr/local/src/

It won't prompt for any password.

Ref:-https://blogs.oracle.com/jkini/entry/how_to_scp_scp_and


No comments:

Post a Comment