jsch连接sftp异常 connection rest

sftp getConnect error : com.jcraft.jsch.JSchException: Session.connect: java.net.SocketException: Connection reset

存在问题:SSH终端连接数最大为10个

解决方案:

1) 修改/etc/ssh/sshd_config中#MaxStartups,将其改为MaxStartups 1000

2) 重启SSH服务,/etc/init.d/ssh restart

Debian系统默认连接时间120秒,如果远程终端连接数过多,则会出现超时连接,解决办法如下:

1) 修改/etc/ssh/sshd_config中LoginGraceTime 120,将其改为LoginGraceTime 0,其中0表示不限制连接时间

2) 重启SSH服务,/etc/init.d/ssh restart

注:重启TELNET服务,/etc/init.d/xinetd restart

重启FTP服务,/etc/init.d/vsftpd restart

另外,/etc/security/limits.conf 也可以修改最大连接数,但对SSH服务不生效。

存在问题:SSH终端连接数最大为10个 这句话实际描述不是十分恰当,MaxStartups默认确实是10(linux),但是这个数字是链接队列中等待握手的数。如果这个数字太小,当并发链接超过10的时候就会出现:

connection is closed by foreign host 。

检查下网络、防火墙,还有你的ip设置