Reputation: 29
I have a PC-1 in my home and need to transfer files back and forth to my PC-2 at my University.
The problem is that PC-2 has only access to local network.
So, in order to access it from home I have to ssh to the University server and only then ssh to PC-2.
I know that scp can transfer files between two PCs, but did not find anything in documentation for when there is a server in the middle.
Can it be done with scp or other tool?
Upvotes: 0
Views: 2028
Reputation: 4750
Alternative answer if the ssh tunnel is disabled on the server side :
PC-2
to PC-1
ssh university-server 'ssh PC-2 "cat remotefile"' > localfile
PC-1
to PC-2
ssh university-server 'ssh PC-2 "cat > remotefile"' < localfile
Explanation :
You are asking university-server
to ssh to PC-2
with the specified command ( in this case cat
) and using pipe redirection to write or read from local files
PS: Modified the answer according to working correction in the comment
Upvotes: 2
Reputation: 4750
You can use an ssh tunnel, to connect to PC-2
from PC-1
using university-server
as an intermediate.
Establish the tunnel
ssh -f -N university-server -L 2222:PC-02:22
the tunnel will be kept in background until the ssh
process is killed
scp file transfert
scp -P 2222 user@localhost:file .
scp -P 2222 file user@localhost:path
Upvotes: 1