Connection closed by foreign host.

1. 问题描述

在xshell下用ssh登录远程主机centos出现以下问题:

Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Connection closed by foreign host.

Type `help' to learn how to use Xshell prompt.
Xshell:\> 

之前用xshell远程登录centos都是可以的, 就在我重装了openssh-server后出现这问题, 于是我猜这可能是ssh配置文件/etc/ssh/sshd.conf的问题

2. 解决方法

编辑ssh配置文件/etc/ssh/sshd.conf:

# vim /etc/ssh/sshd.conf

找到下面的X11Forwarding yes, 将其改为no或在前面加#注释即可。

X11Forwarding设置是否允许X11转发

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none

重启ssh服务:

# service sshd restart

OK, 这就是我遇到的问题及其解决方法。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值