There are two ways to solve this problem:
1. SSH login without password.
NOTE: this part based on follows article: http://linuxproblem.org/art_9.html
Your aim: You want to use OpenSSH to enable automatic job submission. Therefore you need an automatic login from hostA / userA to hostB / userB. You don’t want to enter any passwords, because you want to call ssh from within a shell script.
How to do it: First log in on A as user A and generate a pair of authentication keys. Do not enter a passphrase:
userA@hostA:~> ssh-keygen -t rsa Generating public/private rsa key
pair.
Enter file in which to save the key (/home/userA/.ssh/id_rsa):
Created directory '/home/userA/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/userA/.ssh/id_rsa.
Your public key has been saved in /home/userA/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 userA@hostA
Now use ssh to create a directory /.ssh as userB on hostB with portB. (The directory may already exist, which is fine):
userA@hostA:~> ssh -p portB userB@hostB 'mkdir -p .ssh' userB@hostB's
password:
Finally append A’s new public key to userB@hostB: .ssh/authorized_keys and enter B’s password one last time:
userA@hostA:~> cat .ssh/id_rsa.pub | ssh -p portB userB@hostB'cat >>
.ssh/authorized_keys'.
userB@hostB's password:
From now on you can log into hostB as userB from hostA as userA without password:
userA@hostA:~> ssh -p portB userB@hostB
2. You will need to copy the public key from your local machine (directory ./ssh or ./ssh2) to the remote cluster. Here is the list of commands you need to execute:
local # ssh-keygen -t dsa
local # scp ~/.ssh2/id_dsa.pub oganov@palu.cscs.ch:~/.ssh/tmp.pub
remote # cd ~/.ssh/
remote # ssh-keygen -f tmp.pub -i >> authorized_keys
remote # rm tmp.pub