tdc*_*tdc 6 linux openssh portforwarding tunneling ssh-tunnel
我有一个特定的场景,我想解决.我目前通过端口转发连接到主机:
laptop -> gateway -> remote_server_1
Run Code Online (Sandbox Code Playgroud)
和另一位主持人:
laptop -> remote_server_2
Run Code Online (Sandbox Code Playgroud)
使用无密码登录.这两个远程服务器都不对外界可见.现在我正在remote_server_2上运行一项服务,我希望能够访问remote_server_1.我认为我必须设置从remote_server_1到我的笔记本电脑的反向端口转发,然后再到remote_server_2,但我不知道如何做到这一点.以前有人遇到过这种情况吗?
编辑:完整的解决方案,以防其他人需要它:
mylaptop$ ssh -L 3001:localhost:3000 server_2
server_2$ netcat -l 3000
Run Code Online (Sandbox Code Playgroud)
然后通过以下gateway方式设置隧道server_1:
ssh -t -t -L 3003:server_1:22 gateway
Run Code Online (Sandbox Code Playgroud)
然后从server_1以下位置访问:
ssh -R 3002:localhost:3001 -p3003 localhost
echo "bar" | nc localhost 3002`
Run Code Online (Sandbox Code Playgroud)
嘿presto server_2显示bar:-)
您必须完全按照您的描述进行操作。在 上设置服务器server_2。
mylaptop$ ssh -L 3001:localhost:3000 server_2
server_2$ netcat -l 3000
Run Code Online (Sandbox Code Playgroud)
然后从 访问它server_1。
mylaptop$ ssh -R 3002:localhost:3001 server_1
server_1$ echo "foo" | netcat localhost 3002
Run Code Online (Sandbox Code Playgroud)
server_2将会呈现foo。
| 归档时间: |
|
| 查看次数: |
3202 次 |
| 最近记录: |