Tuesday, November 30, 2010

SSH and SCP without password prompt

Establishing SSH connectivity between 2 servers without being asked for password

To be able to execute remote shell commands (ssh, rsh) between 2 trusted servers without being prompted to introduce password each time you have to do the following:

1. Create a key pair on the server from which ssh or scp commads are executed.

ssh-keygen –t rsa

2. Please set empty password.

3. Then you should name the public key more conveniently.

cp $HOME/.ssh/id_rsa.pub $HOME/server1.pub

4. After that copy the public key to the remote server machines:

scp $HOME/server1.pub user@server2:

5. Eventually SSH to these machines and configure the public key as an authorized key.

ssh user@server2

cat $HOME/server1.pub >> $HOME/.ssh/authorized_keys

6. To test the connectivity, simply SSH from server1 machine to server2 machine.

ssh user@server2

The connection should succeed and you should not be asked for a password.

No comments:

Post a Comment