Rootop 服务器运维与web架构

key type ssh-rsa not in PubkeyAcceptedAlgorithms

xshell7连接Amazon Linux 2023系统,提示秘钥未在远程主机注册。

# ssh版本

[root@ip-172-31-36-0 ~]# ssh -V
OpenSSH_8.7p1, OpenSSL 3.0.8 7 Feb 2023

# 内核

[root@ip-172-31-36-0 ~]# uname -r
6.1.19-30.43.amzn2023.x86_64

# openssl

[root@ip-172-31-36-0 ~]# openssl version
OpenSSL 3.0.8 7 Feb 2023 (Library: OpenSSL 3.0.8 7 Feb 2023)

# /var/log/secure日志提示

userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms [preauth]

百度说/etc/ssh/sshd_config加上

PubkeyAcceptedKeyTypes +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa

这2行可以解决,但是还是无法登录。

但是通过git软件包中的git bash here执行ssh -i rsa_id root@xxxx 是可以连接。

# 有资料说新版本ssh不支持rsa sha1,然后在本地通过git软件包自带的命令行创建 rsa-sha2-512 类型秘钥
# 查看ssh-keygen 支持创建哪些类型

-t dsa | ecdsa | ecdsa-sk | ed25519 | ed25519-sk | rsa
	 Specifies the type of key to create.  The possible values are “dsa”, “ecdsa”, “ecdsa-sk”, “ed25519”, “ed25519-sk”, or “rsa”.

	 This flag may also be used to specify the desired signature type when signing certificates using an RSA CA key.  The available RSA signature variants
	 are “ssh-rsa” (SHA1 signatures, not recommended), “rsa-sha2-256”, and “rsa-sha2-512” (the default).

 

$ ssh-keygen -t rsa-sha2-512 -f rsa-sha2-512

将私钥导入xshell中还是提示秘钥未注册,但是在git bash here中还是可以连接。

# 放弃rsa,在本地通过git软件包自带的git bash here命令行创建 ed25519 类型秘钥

$ ssh-keygen.exe -t ed25519 -f ed25519

导入到xshell中才可以连接

# 参考信息,里面有关闭安全策略方法
https://help.aliyun.com/document_detail/460037.html

原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/5278.html

作者:Venus

服务器运维与性能优化

评论已关闭。