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 密钥类型支持

查看远程效果

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

相关推荐
zhengfei6111 天前
AutoPentestX – Linux 自动化渗透测试和漏洞报告工具
linux·运维·自动化
我材不敲代码1 天前
在Linux系统上安装MySQL
linux·运维·服务器
yuezhilangniao1 天前
阿里云服务器Alibaba Cloud Linux 3 安装Python3.11简明指南
linux·运维·python3.11
程序 代码狂人1 天前
CentOS7初始化配置操作
linux·运维·开发语言·php
芋圆奶绿,要半t1 天前
ubuntu20/2204修改系统时间的命令
ubuntu
历程里程碑1 天前
Linux15 进程二
linux·运维·服务器·开发语言·数据结构·c++·笔记
H Journey1 天前
Linux su 命令核心用法总结
java·linux·服务器·su
PPPPPaPeR.1 天前
环 境 变 量
linux·运维·windows
HalvmånEver1 天前
Linux:线程创建与终止上(线程五)
java·linux·jvm
嵌入小生0071 天前
双向链表、双向循环链表之间的异同---嵌入式入门---Linux
linux·c语言·数据结构·链表·嵌入式·小白