openssh 升级到9.8p1 使用scp Unable to negotiate with 192.168.8.8 port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss

原因是 OpenSSH 版本之间的不兼容性。您的客户端 OpenSSH 版本为 9.8,而远程服务器的版本为 5.3。较旧版本的 OpenSSH 5.3 支持的加密算法 (ssh-rsa, ssh-dss) 在较新版本的 OpenSSH 9.8 中已经不再被支持

  1. OpenSSH 7.0 (2015年8月):

    • ssh-dss 密钥类型被标记为"已弃用"(Deprecated)。
    • 新安装的 OpenSSH 7.0 服务器将不再支持 ssh-dss 密钥类型。
    • 已部署的旧版 OpenSSH 服务器仍可继续支持 ssh-dss 密钥类型。
  2. OpenSSH 8.0 (2018年1月):

    • ssh-dss 密钥类型被正式移除。
    • 新版 OpenSSH 8.0 及以上版本将不再支持 ssh-dss 密钥类型。
    • 旧版 OpenSSH 服务器依然可能会继续支持 ssh-dss 密钥类型。
  3. OpenSSH 9.0 (2021年3月):

    • 在 OpenSSH 9.0 及以上版本中,ssh-dss 密钥类型的支持已经被完全删除。
    • 这意味着任何使用 OpenSSH 9.0 及更高版本的客户端和服务器都将不再支持 ssh-dss 密钥类型。

所以总结来说:

  • OpenSSH 7.0 开始标记 ssh-dss 为弃用。
  • OpenSSH 8.0 正式移除了 ssh-dss 密钥类型的支持。
  • OpenSSH 9.0 及更高版本完全删除了 ssh-dss 密钥类型

A机器: 192.168.105.218  OpenSSH_9.8p1  系统版本:centos 7.5
B机器: 192.168.84.68    OpenSSH_5.3p1  系统版本:centos 6.3
所有拉取和推送都是非root用户
A机器sshd_config文件

[root@A机器 ~]# grep -v '^\s*$\|^#' /etc/ssh/sshd_config
PermitRootLogin yes
PubkeyAuthentication yes
AuthorizedKeysFile	.ssh/authorized_keys
PasswordAuthentication yes
UsePAM yes
Subsystem	sftp	/usr/libexec/sftp-server
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,sntrup761x25519-sha512@openssh.com,diffie-hellman-group1-sha1
PubkeyAcceptedKeyTypes  ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512
HostKeyAlgorithms +ssh-rsa

B机器sshd_config文件

[root@B机器 ~]#  grep -v '^\s*$\|^#' /etc/ssh/sshd_config
Protocol 2
SyslogFacility AUTHPRIV
PasswordAuthentication yes
ChallengeResponseAuthentication no
GSSAPIAuthentication no
GSSAPICleanupCredentials yes
UsePAM yes
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS
X11Forwarding yes
UseDNS no
Subsystem	sftp	/usr/libexec/openssh/sftp-server

第一种:问题复现: 高版本openssh拉推低版本openssh
A机器去拉B机器上文件

A机器去推送文件到B机器上

问题报错一致

解决方法
拉取  scp -o "HostKeyAlgorithms=+ssh-rsa"  xxx@192.168.84.68:/home/xxx/log.py .

推送 scp -o "HostKeyAlgorithms=+ssh-rsa" log1.py xxx@192.168.84.68:/home/xxx/

 此方式有些繁琐可以加入alias

以 Bash 为例,您可以在 ~/.bashrc 文件中添加以下内容:
alias scp_rsa='scp -o "HostKeyAlgorithms=+ssh-rsa"'
保存文件后,运行 source ~/.bashrc 使配置生效。


第二种: 问题复现 低版本openssh拉推高版本openssh
B机器去拉A机器上文件

B机器去推送文件到A机器上

解决方法

在/etc/ssh/sshd_config 添加一行
HostKeyAlgorithms ssh-rsa
sshd -t #检查sshd_config语句
systemctl restart sshd

拉取  scp   xxx@192.168.105.218:/home/xxx/log1.py  .

推送 scp  ./log.py  xxx@192.168.105.218:/home/xxx/

 

posted @ 2024-07-16 19:59  Armored-forces  阅读(565)  评论(0)    收藏  举报