免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123下一页
最近访问板块 发新帖
查看: 12084 | 回复: 27
打印 上一主题 下一主题

[系统管理] 公网 SSH 访问报错:Connection closed by foreign host [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2015-11-24 13:30 |只看该作者 |倒序浏览
SSH 局域网访问Linux正常,公网访问报错Connection closed by foreign host
之前就是正常访问的,不知道为什么最近访问不了了!!!
路由器上端口映射是没得问题的,我服务器上还装了mysql tomcat   这些在公网访问都是可以正常访问,
在网上搜了很多资料 照着做了 就没起到作用,也许和我的问题本质不一样,
有时候很奇怪,通过公网IP SSH 在xshell上面可以连上大概1秒钟然后报错,有时候直接报错Connection closed by foreign host

之前也用域名解析外网IP访问,同样mysql tomcat可以访问, ssh报同样错误。
GIF record:
于是我在Linux上 ssh -vv root@14.105.94.112 或者 ssh -vv root@我的域名   输出都是如下:

  1. [root@topsoft ~]# ssh -vv root@14.105.94.112
  2. OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
  3. debug1: Reading configuration data /etc/ssh/ssh_config
  4. debug1: /etc/ssh/ssh_config line 56: Applying options for *
  5. debug2: ssh_connect: needpriv 0
  6. debug1: Connecting to 14.105.94.112 [14.105.94.112] port 22.
  7. debug1: Connection established.
  8. debug1: permanently_set_uid: 0/0
  9. debug1: identity file /root/.ssh/id_rsa type -1
  10. debug1: identity file /root/.ssh/id_rsa-cert type -1
  11. debug1: identity file /root/.ssh/id_dsa type -1
  12. debug1: identity file /root/.ssh/id_dsa-cert type -1
  13. debug1: identity file /root/.ssh/id_ecdsa type -1
  14. debug1: identity file /root/.ssh/id_ecdsa-cert type -1
  15. debug1: identity file /root/.ssh/id_ed25519 type -1
  16. debug1: identity file /root/.ssh/id_ed25519-cert type -1
  17. debug1: Enabling compatibility mode for protocol 2.0
  18. debug1: Local version string SSH-2.0-OpenSSH_6.6.1
  19. debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
  20. debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000
  21. debug2: fd 3 setting O_NONBLOCK
  22. debug1: SSH2_MSG_KEXINIT sent
  23. debug1: SSH2_MSG_KEXINIT received
  24. debug2: kex_parse_kexinit: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
  25. debug2: kex_parse_kexinit: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-dss-cert-v00@openssh.com,ssh-ed25519,ssh-rsa,ssh-dss
  26. debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
  27. debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
  28. debug2: kex_parse_kexinit: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
  29. debug2: kex_parse_kexinit: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
  30. debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
  31. debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
  32. debug2: kex_parse_kexinit:
  33. debug2: kex_parse_kexinit:
  34. debug2: kex_parse_kexinit: first_kex_follows 0
  35. debug2: kex_parse_kexinit: reserved 0
  36. debug2: kex_parse_kexinit: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
  37. debug2: kex_parse_kexinit: ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519
  38. debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
  39. debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
  40. debug2: kex_parse_kexinit: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
  41. debug2: kex_parse_kexinit: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
  42. debug2: kex_parse_kexinit: none,zlib@openssh.com
  43. debug2: kex_parse_kexinit: none,zlib@openssh.com
  44. debug2: kex_parse_kexinit:
  45. debug2: kex_parse_kexinit:
  46. debug2: kex_parse_kexinit: first_kex_follows 0
  47. debug2: kex_parse_kexinit: reserved 0
  48. debug2: mac_setup: setup hmac-md5-etm@openssh.com
  49. debug1: kex: server->client aes128-ctr hmac-md5-etm@openssh.com none
  50. debug2: mac_setup: setup hmac-md5-etm@openssh.com
  51. debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com none
  52. debug1: kex: curve25519-sha256@libssh.org need=16 dh_need=16
  53. debug1: kex: curve25519-sha256@libssh.org need=16 dh_need=16
  54. debug1: sending SSH2_MSG_KEX_ECDH_INIT
  55. debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
  56. debug1: Server host key: ECDSA b0:49:62:d0:9f:99:62:49:f2:cc:dd:09:e7:c3:4b:9f
  57. debug1: Host '14.105.94.112' is known and matches the ECDSA host key.
  58. debug1: Found key in /root/.ssh/known_hosts:4
  59. debug1: ssh_ecdsa_verify: signature correct
  60. debug2: kex_derive_keys
  61. debug2: set_newkeys: mode 1
  62. debug1: SSH2_MSG_NEWKEYS sent
  63. debug1: expecting SSH2_MSG_NEWKEYS
  64. debug2: set_newkeys: mode 0
  65. debug1: SSH2_MSG_NEWKEYS received
  66. debug1: Roaming not allowed by server
  67. debug1: SSH2_MSG_SERVICE_REQUEST sent
  68. debug2: service_accept: ssh-userauth
  69. debug1: SSH2_MSG_SERVICE_ACCEPT received
  70. debug2: key: /root/.ssh/id_rsa ((nil)),
  71. debug2: key: /root/.ssh/id_dsa ((nil)),
  72. debug2: key: /root/.ssh/id_ecdsa ((nil)),
  73. debug2: key: /root/.ssh/id_ed25519 ((nil)),
  74. debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
  75. debug1: Next authentication method: gssapi-keyex
  76. debug1: No valid Key exchange context
  77. debug2: we did not send a packet, disable method
  78. debug1: Next authentication method: gssapi-with-mic
  79. debug1: Unspecified GSS failure.  Minor code may provide more information
  80. Cannot determine realm for numeric host address

  81. debug1: Unspecified GSS failure.  Minor code may provide more information
  82. Cannot determine realm for numeric host address

  83. debug1: Unspecified GSS failure.  Minor code may provide more information


  84. debug1: Unspecified GSS failure.  Minor code may provide more information
  85. Cannot determine realm for numeric host address

  86. debug2: we did not send a packet, disable method
  87. debug1: Next authentication method: publickey
  88. debug1: Trying private key: /root/.ssh/id_rsa
  89. debug1: Trying private key: /root/.ssh/id_dsa
  90. debug1: Trying private key: /root/.ssh/id_ecdsa
  91. debug1: Trying private key: /root/.ssh/id_ed25519
  92. debug2: we did not send a packet, disable method
  93. debug1: Next authentication method: password
  94. root@14.105.94.112's password:
  95. debug2: we sent a password packet, wait for reply
  96. Connection closed by 14.105.94.112
复制代码

论坛徽章:
0
2 [报告]
发表于 2015-11-24 13:32 |只看该作者
自挽。。。。  求帮忙分析。。。。

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
3 [报告]
发表于 2015-11-24 14:11 |只看该作者
是不是你的key有问题?看你贴出来的,key认证没通过,转向password认证了

论坛徽章:
0
4 [报告]
发表于 2015-11-24 18:28 |只看该作者
回复 3# chenyx


    我把key认证关了也是一样,最开始没有打开证书认证  可以通过外网IP 用账号密码访问,前两天突然访问不了了,找不到原因,ssh我都重装了 还是不行。

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
5 [报告]
发表于 2015-11-24 18:58 |只看该作者
http://bbs.chinaunix.net/thread-1863631-1-1.html
看看这个帖子的方法能不能解决

论坛徽章:
0
6 [报告]
发表于 2015-11-24 20:13 |只看该作者
回复 5# chenyx


谢谢,但是无效,按照下面这个也设置了,还是同样的,比较奇怪的是 通过外网IP连接  在xshell里面 貌似连上了  1秒就断开
# vi /etc/ssh/ssh_config
设置:GSSAPIAuthentication no
# vi /etc/ssh/sshd_config
设置:GSSAPIAuthentication no
设置:UseDNS no

求职 : Linux运维
论坛徽章:
203
拜羊年徽章
日期:2015-03-03 16:15:432015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:57:092015小元宵徽章
日期:2015-03-06 15:58:182015年亚洲杯之约旦
日期:2015-04-05 20:08:292015年亚洲杯之澳大利亚
日期:2015-04-09 09:25:552015年亚洲杯之约旦
日期:2015-04-10 17:34:102015年亚洲杯之巴勒斯坦
日期:2015-04-10 17:35:342015年亚洲杯之日本
日期:2015-04-16 16:28:552015年亚洲杯纪念徽章
日期:2015-04-27 23:29:17操作系统版块每日发帖之星
日期:2015-06-06 22:20:00操作系统版块每日发帖之星
日期:2015-06-09 22:20:00
7 [报告]
发表于 2015-11-24 23:53 |只看该作者

论坛徽章:
45
2016猴年福章徽章
日期:2016-02-18 16:42:24平安夜徽章
日期:2015-12-27 09:46:0315-16赛季CBA联赛之八一
日期:2015-12-15 17:08:23黄金圣斗士
日期:2015-12-11 09:16:31天蝎座
日期:2015-12-11 09:16:22戌狗
日期:2015-12-11 09:16:19程序设计版块每周发帖之星
日期:2015-12-11 09:15:21操作系统版块每周发帖之星
日期:2015-12-11 09:15:16IT运维版块每周发帖之星
日期:2015-12-11 09:15:09IT运维版块每月发帖之星
日期:2015-12-11 09:15:01CU十四周年纪念徽章
日期:2015-12-11 09:14:40操作系统版块每日发帖之星
日期:2015-12-11 09:13:36
8 [报告]
发表于 2015-11-25 08:11 |只看该作者
不明所以,换个登录工具试试

论坛徽章:
0
9 [报告]
发表于 2015-11-25 09:26 |只看该作者
回复 7# lyhabc


    阅ing  去研究一番ing ...

论坛徽章:
0
10 [报告]
发表于 2015-11-25 09:44 |只看该作者
回复 7# lyhabc


    初步看了下应该是在验证的时候出现的问题,用密码登录,密码肯定是没错的,内网可以正常登录,外网却不可以,怎么去排查?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP