自学内容网 自学内容网

Xshell使用密钥远程登录Ubuntu 22.04报错:所选的用户密钥未在远程主机上注册。请再试一次

报错截图如下:
在这里插入图片描述
问题原因:
Ubuntu 22.04 不支持 Xshell使用的私钥。
查看系统支持的私钥:sudo sshd -T | egrep "pubkey"

~$ sudo sshd -T | egrep "pubkey"
pubkeyauthentication yes
pubkeyacceptedalgorithms ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,rsa-sha2-512,rsa-sha2-256
pubkeyauthoptions none

查看Xshell使用的密钥:

默认使用密钥类型是: ssh-rsa

在这里插入图片描述
到这里就已经清晰了,只需要把ssh-rsa密钥加入到ubuntu 22系统内,就可以远程了。

新增密钥类型支持
配置文件:/etc/ssh/sshd_config

PubkeyAcceptedKeyTypes +ssh-rsa
  • +ssh-rsa 使用 + 表示新增密钥类型支持,不使用 + 表示只支持指定类型的密钥

最后重启sshd

查看密钥是否新增了ssh-rsa

root@bird:/etc/ssh# sudo sshd -T | egrep "pubkey" | grep "ssh-rsa"
pubkeyacceptedalgorithms ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa

可以看出最后已经新增了 ssh-rsa 密钥类型支持

查看远程效果
在这里插入图片描述
最后使用密钥远程连接成功!


原文地址:https://blog.csdn.net/qq_50247813/article/details/142932102

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!