2、非交互式
1)创建公钥对
ssh-keygen -t dsa -f ~/.ssh/id_dsa -P " "
2)发送公钥
sshpass -p123456 ssh-copy-id -i ~/.ssh/id_dsa.pub "-o StrictHostKeyChecking=no -p52113 zhenghao@172.16.1.8"(sshpass需要事先下载编译安装)
3)测试
[zhenghao@web01 ~/.ssh 18:45:59]$ ssh -p52113 172.16.1.8 hostname
web02
原文地址:http://blog.51cto.com/13670729/2118494