rescueshell Start trial

SSH blocked on a work network? Ways around port 22

Every other page here is about the device's network. This one is about yours: the office, hotel or campus Wi-Fi you are sitting on when ssh just hangs.

Check that it is your network

The error tells you where the connection died. Run this against a host you know accepts SSH:

ssh -v -o ConnectTimeout=10 admin@host.example.com

To see if port 22 is the issue, compare it with a port that is open:

nc -vz -w 5 host.example.com 22
nc -vz -w 5 host.example.com 443

If 443 connects and 22 times out from this network, but 22 works from your phone's hotspot, the block is on the network you are on.

The usual workarounds, and where they stop

Tether to your phone

The quickest test, and often the quickest fix. It costs mobile data, and some workplaces do not allow it on a managed laptop.

Run sshd on port 443 as well

If you run the server, add a second port in sshd_config, then reload sshd:

Port 22
Port 443
ssh -p 443 admin@host.example.com

Many networks let 443 out because the web needs it. Some inspect it and drop anything that is not TLS, and the port is no longer free for a web server on the same address. It also only helps for a host you can already reach: a device behind NAT or CGNAT has no address to connect to, whichever port you pick. See SSH without port forwarding.

Go through the network's HTTP proxy

If web traffic leaves through a proxy that allows CONNECT, OpenSSH can use it with a ProxyCommand. With the OpenBSD nc:

ssh -o ProxyCommand='nc -X connect -x proxy.example.com:3128 %h %p' admin@host.example.com

Many proxies allow CONNECT only to port 443, so this is the same host problem as above. It also sends your traffic through a system someone else runs, so check that your workplace allows it.

A VPN you run

A VPN to a server you control, on a port the network allows, gets you out for all traffic. It needs that server, and most VPNs are blocked or noticed on the same kind of network. The trade-offs are in reverse SSH vs a VPN mesh vs a hosted relay.

RescueShell: a shell over HTTPS

A RescueShell shell does not use port 22 from your side. You open it in the web app or with the rescueshell CLI, and it reaches the device through our relay, which the device has already dialled out to. From your network that is HTTPS, with WebSocket, to app.rescueshell.com. The device runs its own OpenSSH server and checks your SSH key against its own list of trusted keys; our servers cannot add a key to it.

The device has to be set up first, from a network where you can reach it, or by someone at its console.

1. Install on the device

In the web app, open Devices, press Add device, name it and press Create pass. Then run this on the device as root:

curl -fsSL https://releases.rescueshell.com/latest/install.sh | sh -s -- \
  --base-url https://releases.rescueshell.com/latest --relay https://app.rescueshell.com \
  --name pump-07 --trust-keys-from pi

Change pi to the account whose keys you log in with, and pump-07 to a name for the device. The installer lists each key it will trust, asks you to confirm, then asks Registration pass or token:. It ends with a host key: line; keep it for your first shell. The device needs Linux with OpenSSH, and outbound TCP 443 with WebSocket allowed. See add a device.

2. Open a shell from the blocked network

Sign in to the web app in your browser and press Open shell on the device. Nothing is installed on the work computer. You confirm with your passkey or authenticator, then give the page your SSH key, in the signed frame, and the first time you type the device's host key: line. See the browser shell. If you can install programs, rescueshell does the same in your own terminal. See the CLI.

Think about that key. Loading a private key into a browser on a computer you do not control is a risk, and a shared or locked-down machine may keep traces. Use a key you are willing to put there, or a separate key for that device, and a passkey-locked saved key if you want it to stay encrypted.

What to know before you rely on it

Commands on this page other than the install command are standard OpenSSH and netcat usage; we did not run them against a blocking firewall for this page. If the device is the one behind a strict network, see what to ask the IT team. If the shell does not open, see the shell does not open.

Try it on one device

The first device is free to try with no card, for 30 days from when it connects, not from when you sign up. Start a trial.