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

报错截图如下:

问题原因:

Ubuntu 22.04 不支持 Xshell使用的私钥。
查看系统支持的私钥:sudo sshd -T | egrep "pubkey"

bash 复制代码
~$ 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

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

最后重启sshd

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

bash 复制代码
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 密钥类型支持

查看远程效果

最后使用密钥远程连接成功!

相关推荐
刘一说1 小时前
TypeScript 与 JavaScript:现代前端开发的双子星
javascript·ubuntu·typescript
石像鬼₧魂石1 小时前
22端口(OpenSSH 4.7p1)渗透测试完整复习流程(含实战排错)
大数据·网络·学习·安全·ubuntu
C Yu小白1 小时前
Linux系统调用与文件操作详解
linux·运维·服务器
ZFB00011 小时前
【麒麟桌面系统】V10-SP1 2503 系统知识——常见用户组简介
linux·运维·kylin
EndingCoder2 小时前
类的继承和多态
linux·运维·前端·javascript·ubuntu·typescript
ZFB00012 小时前
【麒麟桌面系统】V10-SP1 2503 系统知识——添加用户
linux·运维·kylin
ZFB00013 小时前
【麒麟桌面系统】V10-SP1 2503 系统知识——进入救援模式
linux·运维·kylin
RisunJan3 小时前
Linux命令-iptables-restore命令(从文件批量恢复 iptables 防火墙规则)
linux·运维·网络
hugerat4 小时前
在AI的帮助下,用C++构造微型http server
linux·c++·人工智能·http·嵌入式·嵌入式linux
ha20428941945 小时前
Linux操作系统学习记录之----自定义协议(网络计算器)
linux·网络·学习