目的:在A机器免密码SSH登陆B
按照ssh免登陆在A(192.168.1.101)机器生成密要
ssh-keygen -t rsa -P ‘‘ -f ~/.ssh/id_rsa
将生成的id_rsa.pub 拷贝到B(192.168.1.102)
scp ~/.ssh/id_rsa.pub [email protected]:/root/.ssh
然后登陆机器B,执行如下命令:
cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
此时尝试通过Assh连接B
提示输入密码,可能是权限问题,修改B机器相应目录权限,
authorized_keys 权限为644 (chmod 644 authorized_keys)
.ssh 目录的权限是700 (chmod 700 .ssh)
再次尝试,仍提示输入密码!!!!
感觉是生成密要的方式可能会影响,重新执行生成密要操作,并且修改密要类型
ssh-keygen -t dsa -P ‘‘ -f ~/.ssh/id_dsa
scp ~/.ssh/id_rsa.pub [email protected]:/root/.ssh
cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys (原来的并不删除)
再试,无果!!!!!!还是提示输入登陆密码
好,我再忍
将登陆信息打印出来
ssh 192.168.100.102 -v
日志显示:
debug1: Unspecified GSS failure. Minor code may provide more information
Unknown code krb5 195
debug1: Unspecified GSS failure. Minor code may provide more information
Unknown code krb5 195
然后跑到102查看日志
/var/log/secure
日志显示:
bad ownership or modes for directory /root
修改root权限 chmod 755 root
搞定
其实第一次就应该用ssh -v参数查找问题的...