2

I've never had trouble with this until I started using hotspot Wi-Fi instead of my normal Wi-Fi.

I always get connection closed by xx.xxx.xxx.xx when trying to SSH into my Amazon instance:

jeff@jeff-Inspiron-5749:~$ ssh -v -i /path/to/key.pem [email protected]
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /home/jeff/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 9.99.999.99 [9.99.999.99] port 22.
debug1: Connection established.
debug1: identity file /path/to/key.pem type -1
debug1: identity file /path/to/key.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.13
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.13 pat OpenSSH_6.6.1* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr [email protected] none
debug1: kex: client->server aes128-ctr [email protected] none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
Connection closed by 9.99.999.99

EDIT:

I've also tried changing the inbound security rules of my EC2 to accept all ip address: 0.0.0.0/0 and this will sometimes work, but only occasionally. I suspect it may be a connection/speed issue with my hotspot Wi-Fi? But I can stream videos on YouTube just fine...

I've currently whitelisted my hotspot ip address by selecting "use my ip" on Amazon.

EDIT 2:

I switched back to normal wifi just so I could log into my EC2 and look at the /var/log/auth.log file, and this is what I found:

AUG 20 08:05:01: session opened for user root by (uid=0)
AUG 20 08:05:01: session closed for user root 

in many lines... always with the same times. an open and and immediate close.

Traceroute info:

traceroute with normal wifi:

jeff@jeff-Inspiron-5749:~$ traceroute 3.15.182.213
traceroute to 3.15.182.213 (3.15.182.213), 30 hops max, 60 byte packets
 1  192.168.1.1 (192.168.1.1)  0.957 ms  1.382 ms  1.380 ms
 2  * * *
 3  173-219-251-70.suddenlink.net (173.219.251.70)  28.725 ms  28.740 ms  29.351 ms
 4  173-219-243-78.suddenlink.net (173.219.243.78)  32.849 ms  33.736 ms  40.397 ms
 5  173-219-251-42.suddenlink.net (173.219.251.42)  40.376 ms  40.385 ms  43.927 ms
 6  sjo-b21-link.telia.net (213.248.71.92)  43.931 ms  27.817 ms  27.746 ms
 7  kanc-b1-link.telia.net (213.155.132.181)  56.957 ms  62.528 ms  62.489 ms
 8  chi-b22-link.telia.net (62.115.121.231)  74.532 ms  79.607 ms  79.564 ms
 9  a100-ic-320469-chi-b22.c.telia.net (213.248.76.189)  85.049 ms  85.025 ms  90.579 ms
10  52.95.63.36 (52.95.63.36)  93.491 ms 52.95.63.100 (52.95.63.100)  90.982 ms 52.95.63.84 (52.95.63.84)  69.568 ms
11  52.95.63.129 (52.95.63.129)  69.504 ms 52.95.63.81 (52.95.63.81)  67.446 ms 52.95.63.93 (52.95.63.93)  66.798 ms
12  * * *
13  54.239.43.213 (54.239.43.213)  101.916 ms 54.239.43.221 (54.239.43.221)  101.347 ms 54.239.43.213 (54.239.43.213)  93.177 ms
14  * * *
15  52.95.3.38 (52.95.3.38)  92.952 ms 52.95.2.150 (52.95.2.150)  96.277 ms 52.95.2.232 (52.95.2.232)  84.388 ms
16  52.95.2.219 (52.95.2.219)  87.294 ms 52.95.2.137 (52.95.2.137)  88.427 ms 52.95.2.163 (52.95.2.163)  88.596 ms
17  52.95.2.164 (52.95.2.164)  87.236 ms 52.95.2.106 (52.95.2.106)  95.621 ms 52.95.2.252 (52.95.2.252)  99.941 ms
18  52.95.2.171 (52.95.2.171)  85.164 ms 52.95.2.199 (52.95.2.199)  85.299 ms 52.95.2.87 (52.95.2.87)  95.134 ms
19  52.95.1.6 (52.95.1.6)  91.705 ms  91.658 ms 52.95.3.132 (52.95.3.132)  88.059 ms
20  * * *
21  * * *
22  * * *
23  * * *
24  * * *
25  * * *
26  * * *
27  * * *
28  * * *
29  * * *
30  * * *
jeff@jeff-Inspiron-5749:~$

traceroute with hotSpot wifi:

jeff@jeff-Inspiron-5749:~$ traceroute 3.15.182.213
traceroute to 3.15.182.213 (3.15.182.213), 30 hops max, 60 byte packets
 1  192.168.43.1 (192.168.43.1)  104.447 ms  104.446 ms  104.443 ms
 2  249.sub-66-174-31.myvzw.com (66.174.31.249)  168.149 ms  177.345 ms  177.575 ms
 3  * * *
 4  * * *
 5  * * *
 6  171.sub-69-83-164.myvzw.com (69.83.164.171)  177.511 ms  33.417 ms  33.247 ms
 7  3.sub-69-83-164.myvzw.com (69.83.164.3)  33.845 ms  126.625 ms  126.604 ms
 8  232.sub-69-83-160.myvzw.com (69.83.160.232)  126.600 ms  126.577 ms  126.553 ms
 9  122.sub-69-82-83.myvzw.com (69.82.83.122)  126.556 ms  126.551 ms  44.159 ms
10  137.sub-66-174-29.myvzw.com (66.174.29.137)  50.315 ms  50.333 ms  50.723 ms
11  209.116.153.13 (209.116.153.13)  51.129 ms  51.102 ms  51.109 ms
12  207.88.14.197.ptr.us.xo.net (207.88.14.197)  74.258 ms  77.847 ms  77.731 ms
13  52.95.217.244 (52.95.217.244)  77.306 ms 52.95.217.130 (52.95.217.130)  77.072 ms  76.966 ms
14  176.32.125.212 (176.32.125.212)  77.031 ms 176.32.125.164 (176.32.125.164)  74.228 ms 176.32.125.152 (176.32.125.152)  74.386 ms
15  176.32.125.157 (176.32.125.157)  79.744 ms 176.32.125.181 (176.32.125.181)  79.703 ms 176.32.125.203 (176.32.125.203)  79.466 ms
16  * * *
17  52.93.129.119 (52.93.129.119)  106.968 ms 52.93.129.109 (52.93.129.109)  109.956 ms 52.93.129.119 (52.93.129.119)  109.554 ms
18  * * *
19  52.95.2.148 (52.95.2.148)  112.365 ms 52.95.2.30 (52.95.2.30)  104.080 ms 52.95.2.148 (52.95.2.148)  108.191 ms
20  52.95.2.163 (52.95.2.163)  113.684 ms 52.95.2.195 (52.95.2.195)  104.267 ms 52.95.2.111 (52.95.2.111)  102.228 ms
21  52.95.2.168 (52.95.2.168)  104.889 ms 52.95.2.190 (52.95.2.190)  110.505 ms 52.95.2.164 (52.95.2.164)  107.502 ms
22  52.95.3.27 (52.95.3.27)  119.008 ms 52.95.2.199 (52.95.2.199)  112.348 ms 52.95.2.255 (52.95.2.255)  106.043 ms
23  52.95.3.132 (52.95.3.132)  109.461 ms  110.252 ms 52.95.1.2 (52.95.1.2)  109.603 ms
24  * * *
25  * * *
26  * * *
27  * * *
28  * * *
29  * * *
30  * * *
jeff@jeff-Inspiron-5749:~$ 
4
  • Try measuring the connection with iperf running it in -s mode on EC2, then compare results running the client on your computer from hotspot and normal wifi. You may also want to examine results of traceroute and ping to EC2 from both AP's and compare them. Sometimes it's just difficult to bring any conclusion without proper diagnostics in such situations, but the probably reason may be traffic shaping on the hotspot's ISP side.
    – Tim
    Commented Aug 20, 2019 at 18:04
  • I've posted the results from traceroute. pings were fairly similar (normal wifi was about 85ms and hotspot was about 110ms). I got iperf running on the server, but nothing happened when I tried pinging it from the client. Commented Aug 20, 2019 at 18:52
  • You should run iperf -c 3.15.182.213 on your computer in order to connect to EC2's iperf instance, it will measure the connection speed between you and the VPS. Do the same on the normal wifi.
    – Tim
    Commented Aug 21, 2019 at 3:19
  • Thanks for the help tim! I think I may have found the culprit: PLUGGING IN my phone/tablet that provides the hotspot wifi!!! I think tethering may also solve this problem. I noticed that after connecting at least once, from there on I was able to connect without the hotspot wifi being plugged in. Commented Aug 21, 2019 at 13:22

1 Answer 1

0

In case it's helpful to anyone else, I was able to overcome SSH connectivity issues by specifying a slightly more permissive subnet mask on the CIDR block in the security group's inbound rule. Specifically, I was having connectivity issues when using the /32 subnet mask like this:

12.34.56.789/32

but I no longer experience issues when I use the /16 subnet mask like this:

12.34.56.789/16
New contributor
CFL_Jeff is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .