3

First of all, I'm pretty new to SSH. I've used it before, but never had to deal much with setting it up or navigating the details. Migrated from ServerFault.

Whenever I try to ssh to a public ip address from my windows 10 computer, I get an error that looks like ssh: connect to username@<public ip address> port 22: Connection timed out.

I can connect to my own linux machine from windows with a private ip address, and my windows machine connects to github with ssh public/private key authentication. My linux machine can connect to external servers (like AWS) via ssh, it's just my windows machine, and just public IP addresses, so far as I can tell.

Here's the output with the -vv option, and on a different port:

ssh -vv -p 2200 example.com                                                                                  OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5                                                                                       debug2: resolving "example.com" port 2200                                                                                       debug2: ssh_connect_direct: needpriv 0                                                                                          debug1: Connecting to example.com [93.184.216.34] port 2200.                                                                    debug1: connect to address 93.184.216.34 port 2200: Connection timed out                                                        ssh: connect to host example.com port 2200: Connection timed out   

What is causing this problem, and what do I need to do to fix it, so that I can ssh to external servers from my windows 10 computer?

I can ping external servers fine:

Pinging 1.1.1.1 with 32 bytes of data:
Reply from 1.1.1.1: bytes=32 time=23ms TTL=54 
Reply from 1.1.1.1: bytes=32 time=74ms TTL=54
Reply from 1.1.1.1: bytes=32 time=26ms TTL=54
Reply from 1.1.1.1: bytes=32 time=24ms TTL=54
      
Ping statistics for 1.1.1.1:
packets: Sent = 4, Received = 4, Lost = 0 (0% loss),                                                                Approximate round trip times in milli-seconds:                                                                              Minimum = 23ms, Maximum = 74ms, Average = 36ms
9
  • 1
    I think port 22 is not open on the ssh server. Contact the server administrator. If it is a windows server then ask to port forward 22 on ICF. Or if it is a linux server then do sudo ufw allow 22.
    – Wasif
    Jul 11, 2020 at 5:53
  • 1
    The ssh server you are attempting to connect to will have sshd running on one port and that need not be 22. Many servers move ssh to a high port to cut down on the number of unauthorized login attempts they receive. Can you connect to that same site on port 22 from your Linux box? A timeout means either the remote ssh server isn't running -or- it is running on a different port. You can add -vv as the option to increase the amount of debug info you get on the connection Jul 11, 2020 at 8:25
  • I am able to connect to the server (like AWS) with a linux desktop, though- doesn't that mean that the port is open? Perhaps this is a different question, but I'm trying to connect to that linux desktop as a sort of testbed (private works fine on that), so what should I do to make it publicly accessible, and secure?
    – fyzx92
    Jul 11, 2020 at 18:02
  • @JW0914 could you please explain the edits that you made? Why the information in the question was irrelevant?
    – fyzx92
    Jul 11, 2020 at 18:09
  • I rolled back the edit as it removed a lot relevant info (I'm on a cell so I can't edit it easily). That said, there are edits that would be appropriate to cut down statements not relevant to the problem and better format the post.
    – davidgo
    Jul 11, 2020 at 20:27

1 Answer 1

1

There are a number of reasons this could be happening - these are likely due to firewalling going on somewhere.

SSH sits on top of TCP. When you get connection timed out errors it means that the problem is that the SSH client is not seeing any responses from the server (ie the TCP handshake is not completing) which almost always means the problems is not with SSH, rather its at a lower level. This also explains why you get this error on ports that SSH is not listening on.

The first thing I do is examine firewall rules to check they are allowing SSH through. As the problem seems limited to your laptop/desktop, checking the local firewall and AV software is a good place to start.

If that does not solve it, break out traffic sniffers - seeing if the server receives and sends traffic is a useful hint. As its Linux, running something like

  tcpdump -n -i any src or dst XXX.XXX.XXX.XXX 

Can be useful where XXX.XXX.XXX.XXX is your external IP and where your monitoring us taking place from a computer not on the same man as your desktop.(maybe SSH to an intermediate server ie using a cellular connection or vpn?)

If its a complex network you may need to get your network administrator involved. If its a simple network where you are the network admin you might want to suspect an issue with port forwarding on your router and/or bad config related to this.

Using a VPN can "virtually move" the apparent point if your connection and can be useful for diagnosing/bypassing firewall issues.

1
  • 2
    To check the firewall, what exactly should I be looking for? I've got windows defender open, but don't see a clear outbound rule or app permission entry related to ssh. Plenty related to networking and shells, but nothing really stands out to me.
    – fyzx92
    Jul 12, 2020 at 18:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.