Ubuntu 突然不能通过密钥认证登录 SSH 了,PubkeyAuthentication 之类的配置都正常,而且客户端上私钥文件和文件权限都正常,但每一次连接,都只能使用账户密码认证。- debug1: Next authentication method: publickey
- debug1: Offering public key: C:\\ssh\\wxc ED25519 SHA256:i53CE/da84OhRynw7hf0ASgqDPCejC6ts7ffoKHXqe0 explicit
- debug2: we sent a publickey packet, wait for reply
- debug1: Authentications that can continue: publickey,password
- debug2: we did not send a packet, disable method
- debug1: Next authentication method: password
- wxc@wuxiancheng.cn's password:
复制代码- PubkeyAuthentication yes
- AuthorizedKeysFile .ssh/authorized_keys
- PasswordAuthentication yes
- PermitRootLogin yes
复制代码 在服务器上打开一个调试进程。- /usr/sbin/sshd -d -p 55555
复制代码 然后在客户端通过调试端口连接。
服务器调试进程中出现了如下关键信息。
- Authentication refused: bad ownership or modes for directory /home/wxc
- Failed publickey for wxc from 2408:8266:2b01:1646:4477:9744:9bd2:f96c port 57220 ssh2: ED25519 SHA256:i53CE/da84OhRynw7hf0ASgqDPCejC6ts7ffoKHXqe0
复制代码 原来是用户被偷家了。
- ls -dhl /home/wxc
- drwx------ 9 php php 4.0K Jul 31 01:04 /home/wxc
复制代码 改回来吧。
- chown -R wxc:wxc /home/wxc
复制代码 打完,一切恢复正常,收工。 |
|