I am trying to SSH to a remote university machine from a library, but I get the error message:

ssh: connect to host remote.machine.edu port 22: Connection refused

I have previously posted about this, and I have also spoken to the network administrator to try to change the port.

The system administrator said:

I have it listening on port 2222, but it looks like that's being blocked further upstream.

He said he would try to think of a way around it, but it doesn't seem like we have a solution currently.

It was suggested to me to SSH over port 443. Is there a reason that 443 would work if 22 or 2222 didn't?

Any other solutions would also be appreciated.

(The machine is not down).

To clarify:

  • When I SSH to the remote machine everywhere except the library, using the default port (which I guess is 22 from the library error message) it works fine.

  • I'm not sure why the system administrator said he had it listening on port 2222. I assumed that meant that he was trying something different from the 22 that was failing from the library. (Because if it was always 2222, I would NEVER be able to ssh). Either way, he said that it looks like that's being blocked further upstream.

  • Should I ask him to try to listen on port 443?

  • Is there some different way I can get around the problem?

  • 2
    443 is one of the few ports that are not blocked by firewalls. – Moab Sep 4 '19 at 16:15
  • 4
    If the Administrator has configured the SSH service on port 2222, why are you attempting to connect to port 22, which I presume no service is configured to listen to? – Ramhound Sep 4 '19 at 16:18
  • 2
    @user1551817 - So the extremely noisy commentary is confusing. What port is the SSH server configured to use? Is it port 22 or port 2222? Whatever port it is, that should be the only port, that is mentioned in the question other than port 443 (i.e. the port that would be used for a https proxy). I am flagging all comments as "no longer needed", since they provide confusion, not clarity to the problem – Ramhound Sep 4 '19 at 21:07
  • It's entirely possible the library has blocked incoming and outgoing traffic on port 22 for security reasons. I would block any port that wasn't required for the allowed purposes of the network in question. – Ramhound Sep 4 '19 at 21:13

Your system administrator looks a bit confused. My guess is that he has forwarded the public port 22 to local port 2222 on the computer where the SSH server is located, but this has no relation to the problem.

If you can SSH from anywhere except the library, then the problem is with the library. If you are using the library computers or network server, their firewall must be blocking SSH. The library could be using paid software or private data that they wouldn't want to be copied elsewhere.

One solution is not to use the library network. If you have some other network or computer that you can use from the library.

Otherwise, using a port that is never blocked by the firewall, such as 443 which is used for HTTPS, will let you bypass the restriction. But this needs cooperation from the university system administrator.

In particular, the system administrator will have to forward public port 443 on the university router to local port 22 (or 2222?) on the SSH server.

His ability to do so depends on whether the same router is also accepting HTTPS URL queries for the same public IP address. Meaning that the same computer is housing both an SSH server and a Web server.

If this is the case, then port 443 is already taken. The same one port cannot be used for two purposes by two servers. You would need in that case to also contact the network administrator of the library and try to find another port that is not blocked. Then you will need to convince the university administrator to open that port in his firewall and forward it to port 22 (2222?) on the SSH server.

This is becoming complicated. It might be simpler to copy the files to your laptop or USB key and SSH them from outside the library, if the problem is passing files. Again, this would only be possible if the library has not installed any safeguards to block such actions in order to protect its proprietary data.

If you need SSH for other purposes than passing files, and have no other solution than using the library computers or network, you will need to contact the library firewall administrator for a solution.

  • Um, "FTP" isn't mentioned in the question. Also, FTP doesn't use port 22 [unless non-standardly configured to do so]. – mlp Sep 6 '19 at 17:47
  • @mlp: A momentary eclipse of the mind. I replaced FTP by SSH. – harrymc Sep 6 '19 at 18:01

It seems that the library blocks traffic on port 22 (SSH). Probably port 443 (HTTPS) is not blocked, since otherwise users of the library network would not be able to surf the web in a secure manner. If this assumption is true, the easiest solution would be to change the SSH server's listing port to 443.

If this is not possible (e.g. because a webserver is running in parallel to the SSH server and already listening on port 443) you could leverage another SSH server which listens on port 443 as an intermediate hop, like described here

Whichever solution you choose, all circumvent a regulation put in place by the library's network operators. Therefore and to avoid trouble, I suggest you consult the libraries terms of use first.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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