Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
332 views
in Technique[技术] by (71.8m points)

linux - how to transfer data between local and remote server connected via intermediate server?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...