Wednesday, August 18, 2010

ssh connection from chpc to bio1

Suppose we want to passwordless ssh connection from machine A(chpc) to machine B(bio1)


1. On machine B
modify the following line in /etc/ssh/sshd_config
(root privilege is required)

#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys

to

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys


reload configuration

#/etc/init.d/ssh reload

2. On machine A

$ssh-keygen -t rsa

Generating public/private rsa key pair.
Enter file in which to save the key (/MY_HOME/.ssh/id_rsa):
Enter passphrase (empty for no passphrase): THIS_IS_MY_PASSWORD
Enter same passphrase again: THIS_IS_MY_PASSWORD
Your identification has been saved in /MY_HOME/.ssh/id_rsa.
Your public key has been saved in /MY_HOME/.ssh/id_rsa.pub.
The key fingerprint is:
ad:9e:ab:f9:e1:1a:a4:85:16:3b:24:5f:35:b6:76:a7 user@machine


$ls .ssh/
id_rsa id_rsa.pub known_hosts

id_rsa is my private key, and id_rsa.pub is the public key

$scp id_rsa.pub user@machineB:~/.ssh


3.On machine B

$cd .ssh/

$cat id_rsa.pub >>authorized_keys

Now make a test from machine A:

$ssh user@machineB

Enter passphrase for key '/MY_HOME/.ssh/id_rsa': THIS_IS_MY_PASSWORD
user@machineB$ #OK now we are using machineB.


Next, we use ssh-agent and ssh-add to avoid "Enter passphrase for key '/MY_HOME/.ssh/id_rsa'", avoid password completely.

No comments:

Post a Comment