Linux配置本地无密码访问

本机配置无密码访问基本操作步骤:

1.ssh-keygen (效果同ssh-keygen -t rsa 一样,也可以ssh-keygen -t dsa)

 2.ssh-copy-id -i ~/.ssh/id_rsa.pub root@localhost

这两步基本上可以了,如果还是需要输出密码,则执行

chmod -R 700 ~/.ssh

chmod 600 ~/.ssh/authrized_keys

如果还是不行,仍然需要输入密码进行访问,建议查看日志:

cat /var/log/secure

查看具体的错误,常见的错误是/root目录的权限被改动,需要是755,

如果改成777,则会有问题,如我发现我本机的问题是这样的:

Jul 27 21:26:32 student1986 sshd[14103]: Authentication refused: bad ownership or modes for directory /root
Jul 27 21:26:32 student1986 sshd[14103]: Authentication refused: bad ownership or modes for directory /root
Jul 27 21:26:35 student1986 sshd[14104]: Connection closed by ::1
Jul 27 21:26:51 student1986 sshd[14166]: Authentication refused: bad ownership or modes for directory /root
Jul 27 21:26:51 student1986 sshd[14166]: Authentication refused: bad ownership or modes for directory /root
Jul 27 21:26:53 student1986 sshd[14167]: Connection closed by ::1
Jul 27 21:26:55 student1986 sshd[14169]: Authentication refused: bad ownership or modes for directory /root
Jul 27 21:26:55 student1986 sshd[14169]: Authentication refused: bad ownership or modes for directory /root

posted on 2016-07-27 21:36  tneduts  阅读(311)  评论(0编辑  收藏  举报

导航