ssh 免密码登入远程服务器
2014-07-17 16:00 萧 云 阅读(221) 评论(0) 编辑 收藏 举报生成ssh密钥,将公钥上传至远程服务器~/.ssh目录下面(没有的话就建一个):
ssh-keygen -t rsa
scp ~/.ssh/id_rsa.pub root@yourserver.com:/root/.ssh/
登录到远程服务器,导入公钥到authorized_keys(没有建一个):
cd ~/.ssh
cat id_rsa.pub >> authorized_keys
删除公钥
rm id_rsa.pub
本地配置ssh config
Host server1 HostName 1.2.3.4 Port 22722 User root IdentityFile ~/.ssh/id_rsa Host server2 HostName 2.3.4.5 User root
这样就可以ssh server1,ssh server2登录远程服务器了。
参考资料:
http://www.cnblogs.com/dudu/archive/2012/12/11/linux-ssh-without-password.html