Use the key file. This assumes that host a (192.168.100.3) is used to obtain a file for Host B (192.168.100.4). Execute the following command on host A to generate the pairing key: ssh-keygen-t RSA encounters a prompt to enter by default, and the public key is stored in the user directory. The SSH directory, such as root, is stored in:/root/.ssh/id_rsa.pub. Id_ in the. SSH directory Rsa.pub file is copied to host B's ~/.ssh/directory and renamed Authorized_keys to host A to execute commands and Host B to establish trust, example (assuming Host B's IP is: 192.168.100.4): SCP ~/.ssh/id_ Rsa.pub 192.168.100.4:/root/.ssh/authorized_keys Below you can use the SCP, SSH command do not need a password to get Host B files ssh 192.168.100.4 Enter will not need a password. Note: In fact, id_rsa.pub content added to the other machine Authorized_keys in the line reproduced: http://blog.csdn.net/chris_playnow/article/details/22579139
The issue of entering a password in the shell script to resolve the SCP command