1

How do I ssh over https through a reverse proxy? I have a docker container running a sshd at port 2222. I can ssh into the container locally with ssh -i id_rsa -p 2222 10001@localhost just fine. Once the docker container is hosted, it sits behind a corporate reverse proxy. The deployment layer allows me to expose one port. I don't have the ability to change the reverse proxy configuration. I know it is running an ISTIO sidecar to handle traffic.

I am running an API on the container as well on port 8080. If I expose 8080 during deployment. I would hit the api with a GET request at example.com/myapp/ and it would respond with a 200 code.

I changed the exposed port to 2222 and want to ssh into the container. I can't just ssh into the host because it is at the route /myapp/ behind the reverse proxy example.com. I could set up an ssh tunnel from the container to a different vm server that I have ssh access but I am trying to avoid that.

Is there a way to use an https ssh client to connect to the server? Any help is appreciated.

For example the below command

ssh -v -i id_rsa -p 2222 10001@example.com/myapp/

responds with Could not resolve hostname example.com/myapp/: nodename nor servname provided, or not known

I think I need to use netcat like ProxyCommand=nc -X connect -x example.com/myapp/:2222 %h %p to resolve the proxy. So I do

nc -z example.com 443

and I get Connection to example.com port 443 [tcp/https] succeeded!

slaffy
  • 11
  • 1
  • Does it talk HTTP or HTTPS (you could check it with curl)? You need at least to talk with the correct protocol, ssh alone will not work. Changing the port from 8080 to 2222 will not change anything. Without modifying the endpoint (api) this can't work – jeb May 19 '23 at 06:51
  • ssh and HTTP are different protocols, and you can't tunnel an ssh connection over an HTTP proxy. – David Maze May 19 '23 at 10:49

0 Answers0