可以參考文章: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 root@192.168.1.100
sshpass -p 123456 ssh -p 1000 root@192.168.11.11
2)scp復制文件
sshpass -p '123456' scp root@192.68.1.80:/home/text.txt /root/
sshpass -p '123456' scp -P 2222 root@192.68.1.81:/home/text.txt /root/