/etc/ssh/sshd_config
看起来像这样:Pastebin.ubuntu.com 链接。这是默认的,除了我取消注释授权密钥、pubkey auth 和listenaddress。
然后我做了ssh-copy-id -i ~/.ssh/id_ed25519 user@host
,之后我可以看到该authorized_keys
文件在那里并且是正确的。然后我sshd
用--full-restart
钥匙重新启动。之后我在尝试连接时总是得到以下信息:
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: ED25519 SHA256:Te7bTBJr1zQqeagqlCYl6Vsc19UF1qc67dSRRfBJ6J0 /home/jus/.ssh/id_ed25519
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/jus/.ssh/id_rsa
debug3: no such identity: /home/jus/.ssh/id_rsa: No such file or directory
debug1: Trying private key: /home/jus/.ssh/id_dsa
debug3: no such identity: /home/jus/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/jus/.ssh/id_ecdsa
debug3: no such identity: /home/jus/.ssh/id_ecdsa: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
[email protected]'s password:
如果我禁用密码身份验证,我的权限会立即被拒绝。而且我从来没有被要求输入密钥的密码。
为了测试,我在虚拟机(Xubuntu)上对 sshd 执行了完全相同的步骤,一切正常。我使用了相同的密钥,并且可以从 WSL ssh 客户端进行连接。