If you have configured SSH-access on all machines, you can setup SSH-tunnel via machine B.
First step:
[user@A ~]$ ssh -f -L LOCALPORT:IP_ADDR_C:22 user_at_B@IP_ADDR_B
Key -f
put ssh
to background just before command execution.
Good idea to use -N
key.
From man ssh
:
-N Do not execute a remote command. This is useful for just forwarding ports (protocol version 2 only).
Now you can use scp
:
[user@A ~]$ scp -P LOCALPORT user_at_C@localhost:<your_file_at_C> <local_file>
For example, we'll download file test.txt
from user's me
homedir at machine 192.168.1.1
placed behind machine host.example.com
:
ssh -f -N -L 2222:192.168.1.1:22 [email protected]
scp -P 2222 me@localhost:~/test.txt .
ssh
to login to machine B notscp
.