- 登陆时报错
[root@nebula-api .ssh]# ssh -i .ssh/id.key -p 22 user@host.com
user@host.com's password:
Authenticated with partial success.
Permission denied (publickey).
- 找了2个小时没有找到方法, 加上调试参数也看不错问题
-vvv
- 在服务器端查看日志,
Mar 19 09:02:27 usloftxxx sshd[2621]: Accepted password for user from 192.168.0.100 port 28907 ssh2
Mar 19 09:02:27 usloftxxx sshd[2622]: Connection closed by 192.168.0.100
- 上面的错误信息也看不出问题
- 尝试一些重启 sshd
[root@usloftxxx .ssh]# service sshd restart
Stopping sshd: [ OK ]
Starting sshd: [ OK ]
- 查看日志
tail -f /var/log/secure
Mar 19 09:02:24 usloftxxx sshd[2621]: Authentication refused: bad ownership or modes for directory /home/user
- 最终找到问题,是home目录的权限被其他人修改了 .......
[user@usloft3594 ~]$ ll -d ~
drwxrwx--- 12 user user 4096 Mar 19 17:00 /home/user
- 修正用户权限后即可解决问题
chmod 700 ~
网友评论