Thursday, 4 July 2019

linux - scp/sshfs on a remote 'not direct acessable' machine


Maybe the title must be changed but I have the following situation:




  • I can ssh to a host A




  • From A, I can ssh into a machine B, but this machine cannot be accessed from my computer. The name of the machine (as well as its ip) is local only.




  • How can I sshfs (and/or use scp) directly to machine B, without having to scp files from B->A and then from A->my machine. I'm really loosing productivity that way,




PS: I can't change configs in A nor B...



Answer



If you authenticate to B with credentials accessible on your computer (let’s call it W), for example a password/username tuple (rather than keys on A), you can build a SSH tunnel, for example:


W $ ssh -L 1234:B:22 A

and then


W $ ssh -p 1234 usernameB@127.0.0.1

or similarly with scp and sshfs. I. e. port 1234 on your local machine (usually 127.0.0.1 or ::1) is forwarded to B, port 22 from the perspective of A.


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...