SSH login cannot specify a password on the command line. The emergence of Sshpass solves this problem. Sshpass for non-interactive SSH password authentication, generally used in the sh script, no need to enter the password again.
It allows you to specify a plaintext password with the-p parameter, and then directly log on to the remote server, which supports the password reading from the command line, file, and environment variables.
It is not installed by default and requires manual installation, as follows:
Sshpass Download Address: http://sourceforge.net/projects/sshpass/Download as a tar.gz compression package.
$ TAR-ZXVF sshpass-1.05.tar.gz
$ CD sshpass-1.05
$./configure--prefix=/opt/sshpass #指定安装目录
$ make
$ make Install
$ cp/opt/sshpass/bin/sshpass/usr/bin/
After the above steps, the Sshpass installation completes, the input command sshpass such as appears as follows prompts namely installs successfully:
Specify a password #从命令行方式传递密码-p
$ Sshpass-p ' 123456 ' ssh user_name@host_ip
$ Sshpass-p ' 123456 ' SCP root@host_ip:/home/test/t./tmp/
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/