将连接转发到另一个?
我需要 ssh 两次才能远程访问我的工作计算机。首先我必须通过 ssh 连接到办公室本地服务器。然后我必须 ssh 到我的本地计算机(IP 地址)。没有直接的方法。有没有一种方法,我只需登录一次,它就会以某种方式为我建立连接?我想制作一个 shell 脚本并使用 rsync 来备份我的房子。我相信 rsync 只能处理一个 ssh 连接。有人知道解决这个问题的方法吗?
I need to ssh twice to get to my work computer remotely. First I have to ssh to the office local server. Then I have to ssh to my local computer (ip address). There is no direct way. Is there a way I can just log in once and it will somehow make the connection for me? I want to make a shell script and use rsync to make backups to my house. I believe rsync can only handle the one ssh connection. Anyone know a way around this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您想要使用 ssh 的 ProxyCommand 选项。下面是一个使用一台机器连接到另一台机器的示例。
您可以将以下内容添加到您的 ~/.ssh/config 文件中。
这将首先连接到[电子邮件受保护]并使用它来连接到[电子邮件受保护]< /strong>
现在输入:ssh viatunnel 将使用此配置进行连接。
ProxyCommand 行基本上在连接的第一跳上运行“nc”,并建立到第二个服务器上的端口 22 的隧道。然后外部 ssh 使用它来连接。
请参阅 openssh 处的 ProxyCommand手册
You want to make use of the ProxyCommand option of ssh. Here is an example that uses one machine to connect to another.
You can add the following to your ~/.ssh/config file.
This will connect first to [email protected] and use that to make a connection to [email protected]
Now typing: ssh viatunnel will connect using this configuration.
The ProxyCommand line basically runs 'nc' on the first hop of your connection and establishes a tunnel to port 22 on the second server. Then the outside ssh uses that to connect.
See ProxyCommand here at the openssh manual
是的,您正在寻找的工具称为 ProxyTunnel
Yes, the tool you are looking for is called ProxyTunnel