onsdag den 19. juni 2013

Getting from A to C via B (with ssh)

So this is a very typical, but stupid, real-life problem. I need to get some files from machine A to machine C. I have ssh access to machine A only from machine B. From my local workstation I can access machine B and machine C, but not A (except via B). And to make matters more fun, there isn't enough diskspace on machine B to just move the files there first temporarily. Also I only have root access to my local machine so I can't assume that nice tools like sshfs are installed on the any of the other machines.

Here's my solution:
  • From localhost, create an ssh tunnel B->A:
  • ssh -f B_user@machineB -L 9999:machineA:22 -N
  • Create a mount point for the remote directory
  • mkdir my_mount
  • Mount the remote directory (this prompts for the password on machine A)
  • sshfs -p 9999 A_user@127.0.0.1:/data my_mount
  • ... and just copy the files to machine C,
  • scp my_mount/afile C_user@machineC:/home/C_user/data
     
The crucial part is the third step which mounts the remote directory from machine A on my local machine.

Ingen kommentarer:

Send en kommentar