4

I have the following situation,

(1) local machine ↔︎ (2) cluster gateway ↔︎ (3) cluster machine

and I want to transfer files from my (1) to the (3) and vice versa. There is no way to directly ssh from (1) into (3) though, I can only reach (3) from within (2). Currently I first transfer files from (1) to (2) via sftp, and then from (2) to (3). This is quite cumbersome, in particular since I have a very limited storage on (2).

I found that the answer is likely an ssh tunnel. But I am not sure if this is indeed the way to do it, nor do I know how to set one up or to use it.

I am not an IT guy, and these things are sometimes hard for me to see through. In particular with ssh and ssh keys I want to be careful and make sure that I know what I am doing.

Does anyone perhaps have some insights? Thanks for help!

1 Answer 1

4

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

scp -J user@intermediate /local/path/file.txt user@target:/remote/path/

With older versions (but at least 7.3), you can use ProxyJump directive:

scp -o ProxyJump=user@intermediate /local/path/file.txt user@target:/remote/path

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?


For download, see How can I download a file from a host I can only SSH to through another host?

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .