0

I have three machines. The local machine L, Server1 A, Server2 B.
L is able to connect to A
A is able to connect to B
L is not able to connect to B

I want to copy a file from L to B without taking the extra step to login on A for coppying the data.

Is that possible with scp? If yes, how?

1

L is not able to connect to B, but is B able to connect to L? You didn't say, but I will assume no.

If A is your only way to communicate between B and L then you will definitely have to log in to A at some point. And also, the data will flow through A one way or another (which might be important if A is on a slow connection).

You can establish an SSH tunnel through A in a couple of different ways to get from L to B. For example:

# From L
ssh -L 2222:B:22 -Nf A

Now add the following configuration in ~/.ssh/config on L as a convenience for connecting to B through the tunnel:

Host B
    HostName localhost
    HostKeyAlias B
    Port 2222

Then you can connect to B through the tunnel:

scp file B:

There are other options for setting up this tunnel, including tools to automatically establish the tunnel in the background.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.