找回密码
 新建账号

Ubuntu 突然不能通过密钥认证登录 SSH 了

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

手机版|轻松e站

GMT+8, 2026-7-31 14:16

快速回复 返回顶部 返回列表