ssh 远程执行命令:
https://www.cnblogs.com/youngerger/p/9104144.html
ssh 免密登录:
https://blog.csdn.net/jeikerxiao/article/details/84105529
ssh 登录时候不需要输入 yes:
第一次执行的时候,有的机器可能会提醒输入ssh初次登录询问yes/no,如果要去掉这个yes/no的询问环节,
只需要修改本机的/etc/ssh/ssh_config文件中的"# StrictHostKeyChecking ask" 为 "StrictHostKeyChecking no",
然后重启sshd服务即可
ssh $ip -o StrictHostKeyChecking=no
sshpass 登录:
sshpass -p user_password ssh user_name@192.168.1.2 【登录远程机器】
sshpass -p user_password scp -P22 root@192.168.1.2:/home/test ./ 【远程机器/home/test 复制到本机当前目录】
还可以加参数 -q 【去掉进度显示】
expect 登录:
expect -c " set timeout 1; spawn ssh user@localhost -p 22 ; expect { yes/no { send "yes "; exp_continue } *assword* { send "password " } } ; expect user@* {send " ls -l " } ; expect user@* { send exit } ; expect 100% ; expect eof ; "