开发者社区> 问答> 正文

阿里云 Xshell 连接linux服务器报错Connection closed by foreign host.

Connecting to IP地址:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
Connection closed by foreign host.
Disconnected from remote host(zhengshi_dhy) at 14:15:15.
Type `help' to learn how to use Xshell prompt.

展开
收起
鸿武 2017-03-28 14:46:49 30687 0
3 条回答
写回答
取消 提交回答
  • xshell看到这个日志,一般是远程主机的sshd配置禁止了远程登录/当前用户名登录/当前登录认证方法。具体的错误,需要查看sshd的日志才能知道。

    2019-07-17 20:59:01
    赞同 展开评论 打赏
  • 你先试试用控制台可以登陆不能,如果可以你要判断是你服务器的22端口的问题还是你本地xshell的问题。

    2019-07-17 20:59:01
    赞同 展开评论 打赏
  • 1.服务端日志获取
    tailf /var/log/secure
    2.查看日志报错(如下内容)
    No supported key exchange algorithms
    3.SSH 服务会对相关密钥文件的权限进行检查。比如,私钥文件默认权限是 600,如果配置成 777 等其它权限,导致其它用户也有读取或修改权限。则 SSH 服务会认为该配置存在安全风险,进而导致客户端连接失败。
    可以通过如下指令恢复相关文件的默认权限配置:
    cd /etc/ssh/
    chmod 600 ssh_host_*
    chmod 644 *.pub
    操作示意如下:
    [root@centos]# cd /etc/ssh/
    [root@centos]# chmod 600 ssh_host_*
    [root@centos]# chmod 644 *.pub
    [root@centos]# ll
    total 156
    -rw-------. 1 root root 125811 Nov 23 2013 moduli
    -rw-r--r--. 1 root root 2047 Nov 23 2013 ssh_config
    -rw------- 1 root root 3639 May 16 11:43 sshd_config
    -rw------- 1 root root 668 May 20 23:31 ssh_host_dsa_key
    -rw-r--r-- 1 root root 590 May 20 23:31 ssh_host_dsa_key.pub
    -rw------- 1 root root 963 May 20 23:31 ssh_host_key
    -rw-r--r-- 1 root root 627 May 20 23:31 ssh_host_key.pub
    -rw------- 1 root root 1675 May 20 23:31 ssh_host_rsa_key

      -rw-r--r--  1 root root    382 May 20 23:31 ssh_host_rsa_key.pub
    1. 在用Xshell连接,则可以正常连接
      5.可能每个人,遇到的问题各不相同!请按照一下步骤逐一 排查
      https://help.aliyun.com/knowledge_detail/41470.html
    2019-07-17 20:59:01
    赞同 1 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
阿里云产品十月刊 立即下载
基于阿里云构建博学谷平台实时湖仓 立即下载
阿里云ElasticsearchSeverless版产品发布 立即下载