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 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/
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 and copy,

scp -r root@ /root/.ssh/

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

now form try ssh, scp or rsync as,

scp -r root@ /usr/local/src/

It won't prompt for any password.


No comments:

Post a Comment