简体   繁体   English

我需要从服务器A复制一个文件,该文件只能先连接到服务器B才能访问

[英]I need to copy a file from server A that I can only access by first connecting to server B

I need to copy a file (~9 gigs) from a server, let's call it server B. I can only ssh into server B by first connecting to server A. I am trying to use scp to copy a file to my local machine. 我需要从服务器复制一个文件(约9个演出),我们称它为服务器B。我只能通过首先连接到服务器A来SSH到服务器B。我正在尝试使用scp将文件复制到本地计算机。 I was simply going to use scp to copy the file first to server A, and then again to copy to my local machine - unfortunately though there is only like half a gig of disk space available to me on server A. Is there any way to copy it directly from server B? 我只是简单地使用scp首先将文件复制到服务器A,然后再复制到我的本地计算机-不幸的是,尽管服务器A上只有大约半个磁盘空间可供我使用。有什么方法可以直接从服务器B复制吗? I cannot use ssh to connect to server B directly from my computer. 我无法使用ssh直接从计算机连接到服务器B。 I'm using terminal on mac. 我在Mac上使用终端。

If your computer and the jump host (server A) are both running OpenSSH v7.3 or later, you can use the ProxyJump option to do this automatically: 如果您的计算机和跳转主机(服务器A)都在运行OpenSSH v7.3或更高版本,则可以使用ProxyJump选项自动执行此操作:

scp -oProxyJump=userA@serverA userB@serverB:remoteFile localDest

What this does is open an SSH connection to server A, then tunnel over that to open an SSH (/scp) connection from the local computer to server B, then transfer the file over that connection. 这样做是打开到服务器A的SSH连接,然后通过该通道建立隧道,以打开从本地计算机到服务器B的SSH(/ scp)连接,然后通过该连接传输文件。 Note that it'll ask for two passwords as it connects: first serverA, then serverB. 请注意,它在连接时会要求输入两个密码:首先是serverA,然后是serverB。

You can also automate this by creating an ssh config file on your computer (~/.ssh/config), and making an entry something like this: 您还可以通过在计算机上创建一个ssh配置文件(〜/ .ssh / config)并输入如下内容来实现此目的的自动化:

Host serverB
    ProxyJump userA@serverA

...which tells ssh (and scp) to automatically do the ProxyJump whenever you request a connection to serverB. ...告诉ssh(和scp)在您请求与serverB的连接时自动执行ProxyJump。 See the OpenSSH docs on the config file for more details. 有关更多详细信息,请参见配置文件上OpenSSH文档

If you don't have a new enough OpenSSH on both computers but netcat (or nc or something similar) is available on serverA, you can probably also get the same effect with a ProxyCommand option. 如果两台计算机上都没有足够新的OpenSSH,但是serverA上有可用的netcat (或nc或类似名称),则也可以通过ProxyCommand选项获得相同的效果。 See this superuser question . 请参阅此超级用户问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以将docker qcow2文件从ubuntu服务器复制到我的mac吗? - Can I copy the docker qcow2 file from an ubuntu server to my mac? 我可以复制文件,但不能从Mac终端移动文件 - I can copy file but can not move it from my Mac Terminal 如何访问基于不同网络的FTP服务器 - How I can access FTP server based on different network 如何在终端或GUI中访问mysql社区服务器? - How can I access the mysql community server in terminal or by GUI? 如何复制dmg中.pkg文件旁边的配置。 无法从PackageMaker“预检”脚本访问它 - How do I copy a config placed along side a .pkg file in dmg. Can't access it from PackageMaker “preflight” script 连接时拒绝MySQL服务器访问 - MySQL server access denied while connecting 使用密码将文件从共享文件服务器复制到多个主机 - Copy file to multiple hosts from a shared file server with password 无法从Xcode访问Mac服务器 - Can't access Mac server from Xcode 复制到Web服务器或从Web服务器删除时,如何防止OS X要求管理员密码? - How do I keep OS X from requiring admin password when I copy to or delete from its web server? 我可以通过Microsoft远程桌面授予本地网络摄像头访问Azure Win Server VM的权限吗? - Can I give local webcam access to a Azure Win Server VM through Microsoft Remote Desktop?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM