Password for SSH and SCP – How to Set Up

clusterscpssh

(1) I want to upload some files to a server

for (( i=0 ; i < 23 ; i+=1 )); do  
    echo mypassword | scp tim@xxx.xxx.xxx.xxx:project/$i/train10000/finer_search_c_g ~/project/$i/train10000/  
done

I hope that by pipe my password to scp, the loop will be executed without interaction. However it still asks me to manually input the password. How should I specify mypassword to scp?

(2) I do not use authentication keys generated by ssh-keygen because the server actually is a head node of a cluster. I found that if I use ssh-keygen to generate authentication keys, the files under ~/.ssh will make the access between nodes requiring password, which I cannot find a solution. Is it possible to make the access between nodes with empty password while using authentication keys to access head node from outside the cluster?

THanks and regards!

Best Answer

Use a key file. Place the private keyfile on your client and use ssh-agent to keep the key file loaded in memory, decrypted. Place the public key file on each of the systems you want to access.

Use authentication forwarding to create connections between various hosts without being prompted for authentication.