Xshell 客户端无法连接Linux服务器

版权声明:欢迎交流,转载!保留文章链接即可。 https://blog.csdn.net/qq_21405949/article/details/52539686

阿里云 服务器 特价秒杀活动,优惠券,有需要的自领:https://www.aliyun.com/acts/product-section-2019/new-users?userCode=fr7cmxm9

  • 问题一:Xshel登录提示

报错:

onnecting to 192.168.5.219:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Connection closed by foreign host.

Disconnected from remote host(新建会话 (6)) at 16:32:53.

Type `help' to learn how to use Xshell prompt.

原因:

最大会话数量被限制为1了,vi /etc/ssh/sshd_config

输入/MaxStartups 定位到如下并修改

1) #MaxStartups 10,#去掉,修改10为1000,MaxStartups 1000
2) 重启SSH服务,/etc/rc.d/init.d/sshd restart
#端口连接数
netstat -nat|grep -i '22' |wc -l

问题二:
重启sshd服务时,报错:
Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Could not load host key: /etc/ssh/ssh_host_ed25519_key

原因:

  1. 从提示信息看是sshd守护进程不能加载主机密钥文件,因为找不到这些密钥文件(配置文件/etc/ssh/sshd_config中已定义密

钥文件名与路径);

一般openssh服务正常安装后,主机会自动生成相应的主机密钥文件,但这里因未知原因并没有完成这一步动作,导致无法

远程ssh连接。

解决办法:

ls -al /etc/ssh/ssh*key  #查看key文件是否存在
sudo rm -r /etc/ssh/ssh*key #删除原有key文件
sudo ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
sudo ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
sudo ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key 

重新生成key文件

最后:sudo service sshd restart.重启成功,问题解决!

就可以连接上了!

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_21405949/article/details/52539686