0

I was searching for a way to connect to one of my servers who is behind a jumpbox via SSH. I was able to do so by running the following command:

$ ssh -tt ptitpou@jumpbox ssh -tt ptitpou@targetserver

Now, I want to be able to use that server to access webservers on targetserver's network. For that, I followed this quora answer and I was able to successfully access the websites. The command I used was:

$ ssh -L 127.0.0.1:9999:localhost:9696 -tt ptitpou@jumpbox ssh -D 9696 -tt ptitpou@targetserver

The question I want to ask is how to use the ssh -o ProxyCommand to command in a slightly cleaner way. I tried to put the second part of the command as the proxy command and I had a successful SSH connection, but I was unable to use the proxy after that.

I've also tried this but the command line hangs after connecting to targetserver.

How can I do that? Am I wrong to try to use ProxyCommand option for this task?

  • Can you add the SSH version on each server and client? – muru Apr 11 at 5:13
2

I assume that you are using openssh. The easiest way to do it is to use ProxyJump which appeared recently. You can use it from command line, effectively having the following command:

ssh -J ptitpou@jumpbox -D 9999 -tt ptitpou@targetserver

or from config file:

Host targetserver
    ProxyJump ptitpou@jumpbox
    DynamicForward 9999

Alternatively you can use ProxyCommand:

Host targetserver
    ProxyCommand ssh -W %h:%p ptitpou@jumpbox
    DynamicForward 9999
  • This worked for me, but I needed to edit it a little, otherwise I was getting error : bind [::1]:9999: Cannot assign requested address. This was the line that worked for me : ssh -J ptitpou@jumpbox -D 127.0.0.1:9999 -tt ptitpou@targetserver – ptitpou Apr 11 at 23:21
  • Apparently your ssh insists on using IPv6 and your system doesn't support / enable it... – Tomek Apr 12 at 6:05

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.