1

My setup looks like this:

 +--------+       +----------+      +-----------+
 | Laptop | <---> |  Middle  | <--> |   Server  |
 +--------+       +----------+      +-----------+

And the server is running a web server on TCP:127.0.0.1:8081. All the machines are running SSH and I have credentials to everything.

Before there was the box in the middle, I used to have my SSH config that read:

Host server
    Hostname server.internal.tld
    User ubuntu
    IdentityFile ~/.ssh/some_key.pem
    Port 20022
    LocalForward 8081 localhost:8081
    ServerAliveInterval 60
    KeepAlive yes
    ServerAliveCountMax 1

This let me hit the page in my browser by browsing to localhost:8081.

Is there a line that I can add to my SSH config to get the same result now that there's a machine in the middle that I can proxy SSH through? Is this somehow what ProxyCommand is used for? Will the LocalForward line still work with ProxyCommand?

omghai2u
  • 315
  • 1
  • 6
  • 15

1 Answers1

6

First Check if port 8081 of your web server is accessible from the middle server. If yes then you just have to use ip address of the server instead of localhost in LocalForward configuration. If no add following line in ssh config file

ProxyCommand ssh user_name@middle_server_ip  nc %h %p

LocalForward will work with ProxyCommand.

Gaurav Pundir
  • 1,496
  • 12
  • 14