no pains no gains
分类: 系统运维
2016-07-21 11:03:44
1、下载解压缩tar zxf sshpass-1.05.tar.gz
2、cd sshpass-1.05
./configure;make;make install
which sshpass /usr/local/bin/sshpass sshpass -p XXXX ssh -p 2223 root@10.23.46.39 -o StrictHostKeyChecking=no "uptime" [目标机执行的任务用双引号]
sshpass -p XXXX ssh -p 2223 root@10.23.46.39 -o StrictHostKeyChecking=no对于ssh的第一次登陆,会提示:“Are you sure you want to continue connecting (yes/no)”,这时用sshpass会不好使,解决方法:1.可以在ssh命令后面加上 -o StrictHostKeyChecking=no来解决。比如说上面的命令,就可以写作ssh -p efghi scp abc@192.168.0.5:/home/xxx/test /root -o StrictHostKeyChecking=no。2.或者写入配置文件:把 StrictHostKeyChecking no 加到/etc/ssh/sshconfig 可以让ssh客户端自动接受新主机的hostkey,不用每次都自己输入yes