How to transfer a file between two remote servers using scp from a third, local machine?

后端 未结 6 516
小鲜肉
小鲜肉 2020-12-24 03:04

I\'m trying to copy a file from one remote server to another remote server from my local machine. Here\'s what I\'m trying

6条回答
  •  甜味超标
    2020-12-24 03:25

    The existing answers assume you can ssh back to the local machine from the remote machines. That's not always possible. In such case, you can use a jump host mechanism. It's actually more efficient anyway.


    If you have a recent OpenSSH (8.0), you can use the -J (jump) switch:

    scp -J user@intermediate user@target:/path
    

    With older versions (but at least 7.3), you can use ProxyJump directive, either on command-line:

    scp -o ProxyJump=user@intermediate user@target:/path
    

    or in ssh_config file.


    There are other options like ProxyCommand or port forwarding, which you can use on even older versions of OpenSSH. These are covered in Does OpenSSH support multihop login?

提交回复
热议问题