您的位置:首页 > 其它

ssh免密码自动登录及相关问题解决

2013-04-10 21:37 483 查看
1 自动登录 A为客户端,B为服务器,目的是从A ssh远程登录到B不需输入密码 在A上: #ssh-keygen -t dsa (连续三次回车, 使用缺省值) #scp ~/.ssh/id_dsa.pub [remoteuser]@[remotehost]: 在B上: #cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys #chmod 644 ~/.ssh/authorized_keys 2 问题一: 每次执行ssh [remoteuser]@[remotehost] 都要输入密码, 尽管按照1建立了ssh相互认证 解决办法: A和B的HOME目录的权限必须为700 在A和B上都执行: #chmod -R 700 /home/[user] 在B上, ~/.ssh/authorized_keys权限为644 #chmod 644 ~/.ssh/authorized_keys 2 问题二:ssh或scp连接的时候很慢 解决办法: 最为常见的原因是B上的sshd会去DNS查找访问A IP的hostname, 如果DNS不可用或无相关记录, 则会导致很长的时延 1)在B上/etc/hosts文件中把A的ip和hostname加入 2)在B上/etc/ssh/sshd_config文件中修改或加入 UseDNS=no 3)注释掉/etc/resolv.conf中所有行 4)修改B 上/etc/nsswitch.conf中hosts为hosts:files 5)reboot B 另外也有可能涉及openssh kerberos authenticatioin。 如果执行 ssh -v remoteip, 显示如下: debug1: Next authentication method: gssapi-with-mic debug1: Unspecified GSS failure. Minor code may provide more information No credentials cache found 则在B上/etc/ssh/sshd_config文件中修改 #GSAPI options #GSSAPIAuthentication no #GSSAPIAuthentication yes #GSSAPICleanupCredentails yes #GSSAPICleanupCredentails yes 然后重起sshd /etc/init.d/sshd restart
转载自:http://blog.csdn.net/richardpeng/article/details/3024520
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐