可以参考文章:https://www.cnblogs.com/kaishirenshi/p/7921308.html
安装方式直接通过yum 安装
yum -y install sshpass
常用的方式有以下几种
sshpass -p # 接密码
sshpass -f # 接文件,文件中有密码
示例如下
1)登陆服务器192.168.1.100
sshpass -f 1.txt ssh [email protected]
sshpass -p 123456 ssh -p 1000 [email protected]
2)scp复制文件
sshpass -p '123456' scp [email protected]:/home/text.txt /root/
sshpass -p '123456' scp -P 2222 [email protected]:/home/text.txt /root/