一、配置SSH服务

root@sky9890:~# apt-get install ssh   #安装
root@sky9890:~# systemctl restart ssh
root@sky9890:~# vi /etc/ssh/ssh_config   #配置
sky019899@sky019899-pc:~$sudo vi /etc/ssh/sshd_config
Include /etc/ssh/sshd_config.d/*.conf
Port 22
#AddressFamily any
ListenAddress 0.0.0.0
ListenAddress ::
......
# Authentication:

#LoginGraceTime 2m
PermitRootLogin yes

#Ciphers
#MACs
KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1

二、问题描述

SecureCRT、Xshell等远程工具连接开放麒麟(openKylin)操作系统报如下错误:

Key exchange failed.
No compatible key-exchange method. The server supports these methods: curve25519-sha256,curve25519-sha256@libssh.org,
ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,
diffie-hellman-group18-sha512,diffie-hellman-group14-sha256

三、解决方式

1.方法一

升级远程连接工具,将老版本升级到新版本即可。

2.方法二

注释掉最新的交换密码改为老的秘钥交换

sky9890@sky9890:~$ sudo vi  /etc/ssh/sshd_config
......
#Ciphers
#MACs
KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
#在文件末尾添加新增兼容性的秘钥交换
sky9890@sky9890:~$ sudo systemctl restart ssh
sky9890@sky9890:~$systemctl status sshd #查看sshd服务状态
sky9890@sky9890:~$systemctl start sshd #启动sshd服务
sky9890@sky9890:~$systemctl stop sshd #关闭sshd服务
sky9890@sky9890:~$systemctl is-enabled sshd #查看sshd服务是否设置开机自启
sky9890@sky9890:~$systemctl enable sshd #设置开机自启
sky9890@sky9890:~$systemctl disable sshd #关闭开机自启

root@sky019899-pc:~# lsof -i:22
COMMAND   PID      USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
sshd    10932      root    4u  IPv4 140859      0t0  TCP 192.168.73.129:ssh->192.168.73.1:51522 (ESTABLISHED)
sshd    10945 sky019899    4u  IPv4 140859      0t0  TCP 192.168.73.129:ssh->192.168.73.1:51522 (ESTABLISHED)
sshd    11370      root    3u  IPv6 146178      0t0  TCP *:ssh (LISTEN)
sshd    11370      root    4u  IPv4 146180      0t0  TCP *:ssh (LISTEN)

root@sky019899-pc:~# lsof -i -P | grep ssh
sshd      10932            root    4u  IPv4 140859      0t0  TCP 192.168.73.129:22->192.168.73.1:51522 (ESTABLISHED)
sshd      10945       sky019899    4u  IPv4 140859      0t0  TCP 192.168.73.129:22->192.168.73.1:51522 (ESTABLISHED)
sshd      11370            root    3u  IPv6 146178      0t0  TCP *:22 (LISTEN)
sshd      11370            root    4u  IPv4 146180      0t0  TCP *:22 (LISTEN) 

SecureCRT、Xshell等远程工具连接openKylin操作系统_远程连接

即成功连接openKylin操作系统。