how to transfer data between local and remote serv

2019-09-24 15:45发布

I can login by ssh -X servA from local, then ssh -X servB from servA

To copy data from local to servB, I scp files from local to servA, then from servA to servB.

Is it feasible to copy files from local to servB directly and vice versa?

3条回答
劫难
2楼-- · 2019-09-24 16:10

You can use nc (net cat) as a proxy for ssh.

So for your example, edit your ~/.ssh/config file to look like this:

Host servB
ProxyCommand ssh -q servA nc servB 22

As long as nc is in your path you should now be able to ssh or scp directory to servB

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
查看更多
该账号已被封号
3楼-- · 2019-09-24 16:12

This is what I usually do (I do it in a Mac machine don't know if it's different from a Windows machine):

Once you have set up connection with any of the servA or servB you can do:

Copy from local to servA or servB:

$ scp -P <port-number used>  <file location to copy from> <username_in servA/servB>@localhost:<file location to copy to>

NOTE: This works being in your local machine without ssh-ing to any of the servA/servB, just need to establish connection.

or from servA to servB:

$ scp -P <port-number used>  <username_in servA>@localhost:<file location to copy from> <port-number used> <username_in servB>@localhost:<file location to copy to>

NOTE: I haven't tried this scp from server to server but seems a little bit straight forward.

Just trying to help here.

查看更多
萌系小妹纸
4楼-- · 2019-09-24 16:20

Use ProxyCommand in ssh config file.

查看更多
登录 后发表回答