1

(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!

Tim
  • 1,467
  • 3
  • 25
  • 38

3 Answers3

8

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.

Alex Holst
  • 2,200
  • 1
  • 14
  • 13
3

scp/ssh will test the input stream to check if it is a TTY and if not will try alternate ways to get the password, so plain piping will not work (because the pipe is not a tty).

Cairo
  • 241
  • 1
  • 4
  • Thanks Cairo! Some questions, what is a input stream by TTY, for example? What are the common ways for a input stream? How to know what type of input stream a stdin input to a command is? For example that of ssh/scp. – Tim Feb 26 '10 at 01:26
0

You need to copy the public key to the file .ssh/authorized_keys on the system you want to connect to.

Dominik
  • 2,198
  • 13
  • 9