ssh - 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?
解决方案
确保您使用的是 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 代理流量。
推荐阅读
- pandas - 突出 matplotlib 中的政权变化
- java - 如何使用 Stream 填充矩阵?
- firebase - 从 Firestore 中删除数据时出现 StreamBuilder 错误 - 如何捕获错误
- unix - 在变量中获取 curl 命令的输出
- javascript - 当轮播标题太长时,它会从图像中脱落,如何解决?
- c++ - 如何在 C++17 中实现选项对象?
- python - 更改绑定类中的变量会重复布局并导致 kivy 崩溃
- javascript - 如何拆分缓冲字符串以以特定字节大小作为多个数据包发送?
- ruby-on-rails - 搜索表单找不到具有 'id'= 的用户
- node.js - AWS Elastic Beanstalk 上的 node/express/react 项目无法获取/错误