0

i have a question regarding port forwarding in combination with proxy jump in my ssh config:

Is it possible to make use of DynamicForward from the host used as proxy? Here's my config:

Host proxy
    HostName proxy.private.com
    User user
    IdentityFile ~/path/to/file
    DynamicForward 3000

Host target
    HostName target.somewhere.com
    User user
    IdentityFile ~/path/to/file
    ProxyJump proxy

It does not work with this config, but this would be exactly what i need. Any tips on how to get it to work?

1 Answers1

0

If there is nothing preventing you from using ProxyCommand you can most likely use this approach:

In your ~/.ssh/config file:

Host target
        HostName target.somewhere.com
        User target-user
        IdentityFile ~/path/to/target-user-file
        ProxyCommand ssh -A <proxy-user>@<proxy-host> -i <proxy-user-key> -W %h:%p
        DynamicForward 3000 

You can then run this command on your local machine:

ssh target -D 3000

I was able to test this by running this command locally and retreiving public IP of the target host:

curl -x socks5h://localhost:3000 https://ifconfig.me/

Usefull links I read:

  • More details on these use cases can be found here
  • Detail on this very approach can be found on this site (sadly not in english nor HTTPS)

You can probably define another Host on top to avoid having to mess with ssh parameter each time. This would be done by using CanonicalizeHostname, but I couldn't manage to it. An alias might be more interesting at that point ?

Bleacks
  • 31
  • 4