Search code examples
sshssh-tunnel

Tunnel NETCONF for dynamic host over SSH tunnel


I have a requirement to tunnel NETCONF (typically TCP-22) connections over a jumphost, but for a dynamic host.

I understand I can do remote SSH tunneling for defined hosts, e.g.:

ssh -R 2201:jumphost:22 rtr1
ssh -R 2202:jumphost:22 rtr2

But I'd like to be able to connect to a dynamic host, by tunneling over a jumphost, something like:

ssh -R 2201:jumphost:22 *

And then to be able to make a NETCONF connection such as:

connect rtrN port 2201

Is this doable via SSH tunneling? I don't want to use dynamic SSH tunnels, as I'd have to specify a proxy port whenever I make the connection, which I can't really do when I make the connection.


Solution

  • I've actually figured out how to do this in case anyone is interested:

    In SSH config file:

    Host *.*
            ProxyCommand ssh user@jump nc %h %p
    

    Then anything you SSH to, will forward over the jump connection, then nc to the host.