Skip to content

Contact

Mexico City, Mexico
Available for remote and on-site projects.

Professional networks

LinkedIn · GitHub · Email
Applied engineering, measurable results.

When the network blocks you: HTTP CONNECT tunnels and the SSH banner

· 3 min read · Samuel Torres

Verifying SSH access sounds simple: you connect and see if you get in. But sometimes the problem is not the server or your access, it is the path. On Friday, November 27, while verifying access to a client's server before starting work on it on Monday the 30th, I ran into exactly that: the machine I was testing from had restricted direct outbound network access. The direct connection attempt was cut off before it reached the server. The server was fine; it was my path that was blocked.

First: confirm that the problem is the path, not the destination

When a connection fails, the first thing is to find out where it breaks. Is it the server, which does not respond? Is it your access, which does not work? Or is it your network, which does not let you out? If you do not separate those questions, you spend the day trying random things.

In this case, the clue was clear: the server port responded when tested through the right route, but direct outbound traffic from the test machine was restricted. The server was there and it was fine. What I needed was another way to reach it.

The HTTP CONNECT tunnel

The way out that worked was an HTTP CONNECT tunnel through the outbound proxy. The idea is simple: instead of connecting directly to the server, you ask the proxy to open a tunnel to it, and then you speak SSH inside that tunnel. For the server, the connection arrives the same way; for your network, the only thing going out is a request to the proxy, which is allowed.

An HTTP CONNECT tunnel does not change anything about the SSH protocol: it does not add extra encryption or modify it, it only carries it. For the server, the connection arrives the same way.

This is worth knowing because it happens more than you would think: test machines, office networks, cloud environments and corporate networks restrict direct outbound traffic, and they do not always tell you. When the direct connection fails, before blaming the server, it is worth trying through the outbound proxy your network already uses for everything else.

The banner: proof that you are talking to real SSH

With the tunnel open, the first thing I did was read the server banner. Without authenticating, without sending any credentials, just connecting and listening to what the server says about itself. The banner said SSH-2.0 with OpenSSH 10.2, on Ubuntu.

That reading is worth a lot for three reasons. First: it confirms that what is listening on that port is a real SSH server, and not something else someone put there by accident. An open port guarantees nothing: any service could be listening. Second: it tells you which version is running, and with that you know what to expect. And third: you do not need any credentials to read it, so you can do it before touching your access details, without using up login attempts.

The banner is the server introducing itself. Five seconds of reading tell you more than ten minutes of failed attempts.

The final login with a local forward

For the final login I used a local port forward with socat. Instead of relying on the SSH client's proxy command, I opened a forward on my own machine: the SSH client connected to a local port, and socat carried that connection through the tunnel to the server. The login was done with the key, and it worked on the first try.

Separating the tunnel from the client has a practical advantage: when something fails, you know where to look. If the tunnel does not open, the problem is the network. If the tunnel opens but the login fails, the problem is the access details. Mixing both in a single command means a failure can come from either layer and you do not know which one.

The lesson

When the network does not let you out directly, the server is not broken: you need another path. An HTTP CONNECT tunnel through the outbound proxy gets you there, the banner confirms that you are talking to a real SSH server before you spend your credentials, and a local forward lets you log in without mixing the network with authentication. And all of that, documented, means that on Monday the team starts working instead of debugging the network. Get a quote on WhatsApp in 2 min

Samuel Torres Pichardo

Samuel Torres Pichardo
Software and cloud engineer in Mexico City, with about 3 years of professional experience.
About me · LinkedIn · GitHub · Contact

Got a project in mind?

Hire me: I'll help you build it.

Websites, online stores, custom systems and cloud. Tell me what you need and I'll tell you how I'd build it, what it costs and how long it takes.

  • Mexico City · remote

Menu

Español

[email protected]