1.检查sshd
1.1 查询是否安装ssh
whereis ssh
这里如果安装了ssh,会显示具体位置
1.2 如若没有,则进行安装
sudo apt-get install openssh-server openssh-client
1.3 查询ssh的状态
service sshd status
这里需要ssh处于running状态
2.安装之后还是连接不上
2.1 检查防火墙
sudo ufw status
保持防火墙在inactive状态,如果是active状态,执行下列命令
sudo ufw disable
2.2 Key exchange failed错误
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
如果遇到这个错误则修改/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
注:这一段添加在配置文件的最后即可
2.3 重启sshd
service sshd restart