首页 > 解决方案 > how to create a dynamic port forwarding with several hops?

问题描述

If we have a following situation:

[laptop] ---- [host1] ---- [host2] ----[target]

where host1 is reachable from the my laptop machine, host2 from host1 and the target from host2 only. We have ssh credentials to both host1 and host2.

We can use the dynamic port forwarding with the following command:

ssh -N -D 127.0.0.1:8282 host1_account@host1

and that will basically create a SOCKS4 that we can use with proxychains so that command will work from the kali device:

proxychains ssh host2_account@host2

How we can make a similar (additional?) dynamic tunnel from host2 to target?

标签: sshtunnel

解决方案


确保您使用的是 OpenSSH 7.3 或更高版本,并使用 SSH 的 ProxyJump 功能:ssh -J host1_account@host1 -D 127.0.0.1:8282 host2_account@host2. 这将为您在 host2 上提供一个 SSH 会话,并且 127.0.0.1:8282 将通过 host2 代理流量。


推荐阅读