如何在通过中间服务器连接的本地和远程服务器之间传输数据? [英] how to transfer data between local and remote server connected via intermediate server?
问题描述
我可以通过local
的ssh -X servA
登录,然后servA
的ssh -X servB
I can login by ssh -X servA
from local
, then ssh -X servB
from servA
要将数据从local
复制到servB
,我将scp
文件从local
复制到servA
,然后从 servA
到 servB
.
To copy data from local
to servB
, I scp
files from local
to servA
, then from servA
to servB
.
将文件从local
直接复制到servB
是否可行,反之亦然?
Is it feasible to copy files from local
to servB
directly and vice versa?
推荐答案
您可以使用 nc (net cat) 作为 ssh 的代理.
You can use nc (net cat) as a proxy for ssh.
因此,对于您的示例,请编辑您的 ~/.ssh/config
文件,使其看起来像这样:
So for your example, edit your ~/.ssh/config
file to look like this:
Host servB
ProxyCommand ssh -q servA nc servB 22
只要 nc 在您的路径中,您现在应该能够 ssh 或 scp 目录到 servB
As long as nc is in your path you should now be able to ssh or scp directory to servB
如果您没有 nc,如果您的版本足够新(>= OpenSSH 5.4),您可以使用 ssh -W 来完成,
If you don't have nc you can do it with ssh -W if your version is new enough (>= OpenSSH 5.4),
Host ServB
ProxyCommand ssh -W ServB:22 servA
这篇关于如何在通过中间服务器连接的本地和远程服务器之间传输数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!