1. 下载安装包
https://sourceforge.net/projects/sshpass/
解压并进入到安装包目录
sh
tar -zxvf sshpass-xx.xx.tar.gz
cd sshpass-xx.xx
2. 检验环境,编译源码安装
sh
./configure
make&&make install
3. 检测安装是否成功
sh
▶ sshpass
Usage: sshpass [-f|-d|-p|-e] [-hV] command parameters
-f filename Take password to use from file
-d number Use number as file descriptor for getting password
-p password Provide password as argument (security unwise)
-e Password is passed as env-var "SSHPASS"
With no parameters - password will be taken from stdin
-P prompt Which string should sshpass search for to detect a password prompt
-v Be verbose about what you're doing
-h Show help (this screen)
-V Print version information
At most one of -f, -d, -p or -e should be used
4. 使用
sh
sshpass -p [密码] ssh [用户名]@[服务器地址] -p [端口]