简体   繁体   中英

SSH Config with Port Forwarding and Proxy

I am trying to access a Truenas server at work and I am able to connect to it with ssh proxycommand setup through my config. I am currently able to connect to the servers normally with my ssh config set-up as:


Host proxy_host
    Hostname proxy_host_ip
    User proxy_user
    IdentityFile ~/.ssh/id_rsa_proxy_host
    Port 22


Host truenas_host
    Hostname truenas_host_ip
    User truenas_user
    IdentityFile ~/.ssh/id_rsa_truenas_host
    Port 22
    ProxyCommand ssh -W %h:%p proxy_host

However, I now need to do port forwarding to access the a plugin on the truenas server. I have tried setting-up the port forwarding like this, but with no success.

Host proxy_host
    Hostname proxy_host_ip
    User proxy_user
    IdentityFile ~/.ssh/id_rsa_proxy_host
    Port 22
    LocalForward 8283 truenas_host_ip:8283

Host truenas_host
    Hostname truenas_host_ip
    User truenas_user
    IdentityFile ~/.ssh/id_rsa_truenas_host
    Port 22
    LocalForward 8283 127.0.0.1:8283
    ProxyCommand ssh -W %h:%p proxy_host

However, this is not working. What are the proper ways to set this up, and is LocalForward the best approach, or should I be using DynamicForward or RemoteForward ?

I think you don't need LocalForward on truenas_host . It should be fine with the one of proxy_host cause it means: when I connect to proxy forward the flow going through my local port 8283 to the port 8283 of the truenas_host .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM