使用远程工具secureCRT (版本:Version 7.0.0 (x64 build 326) ) 连接Linux系统 |
1、检查Linux是否安装了ssh-server
输入命令
sudo dpkg -l | grep ssh
打印返回
ii libssh-4:amd64 0.9.3-2ubuntu2.3 amd64 tiny C SSH library (OpenSSL flavor)
ii openssh-client 1:8.2p1-4ubuntu0.9 amd64 secure shell (SSH) client, for secure access to remote machines
2、若不包含ssh-server,就安装
sudo apt-get -y install openssh-server
3、发生报错?
问题重现:打开ssh连接工具发生以下报错
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 |
报错说: 密钥交换失败。没有兼容的密钥交换方法。列举以下的方法 那就来添加交换密钥的方法 |
解决方法
vim /etc/ssh/sshd_config
在尾行输入以下内容
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
然后Esc键,输入:wq保存退出,输入以下命令,重启ssh服务
systemctl restart sshd.service
或
service ssh restart
4、查看ssh服务
4.1 进程信息
输入命令
sudo dpkg -l | grep ssh
打印返回
ii libssh-4:amd64 0.9.3-2ubuntu2.3 amd64 tiny C SSH library (OpenSSL flavor)
ii openssh-client 1:8.2p1-4ubuntu0.9 amd64 secure shell (SSH) client, for secure access to remote machines
ii openssh-server 1:8.2p1-4ubuntu0.9 amd64 secure shell (SSH) server, for secure access from remote machines
ii openssh-sftp-server 1:8.2p1-4ubuntu0.9 amd64 secure shell (SSH) sftp server module, for SFTP access from remote machines
ii ssh-import-id 5.10-0ubuntu1 all securely retrieve an SSH public key and install it locally
4.2 服务状态
输入命令
systemctl status sshd
或
service sshd status
打印返回(成功了!)
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2023-11-26 16:56:39 PST; 17s ago
Docs: man:sshd(8)
man:sshd_config(5)
Process: 56894 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 56895 (sshd)
Tasks: 1 (limit: 4566)
Memory: 1.0M
CGroup: /system.slice/ssh.service
└─56895 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
Nov 26 16:56:39 vac-virtual-machine systemd[1]: Starting OpenBSD Secure Shell server...
Nov 26 16:56:39 vac-virtual-machine sshd[56895]: Server listening on 0.0.0.0 port 22.
Nov 26 16:56:39 vac-virtual-machine sshd[56895]: Server listening on :: port 22.
Nov 26 16:56:39 vac-virtual-machine systemd[1]: Started OpenBSD Secure Shell server.
root用户登录拒绝,参考 🔗使用远程工具连接Linux系统——使用Root用户登录 |