Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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...

share|improve this question

3 Answers 3

up vote 4 down vote accepted

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.

share|improve this answer
    
Works Perfectly! –  SshProblem Oct 8 '12 at 14:10
    
If you want to bind to a specific address locally, for example to allow another computer, W2, on the same network as W, to connect to B’s port 22, simply use W $ ssh -L 198.51.100.1:1234:B:22 A, where 198.51.100.1 is the external IP address of W. –  Claudius Oct 8 '12 at 14:12

If you have netcat on the host A, then ssh's ProxyCommand is your friend.

Edit your local .ssh/config as follows

Host B
    HostName B.internal.domain
    ProxyCommand ssh A nc %h %p 2> /dev/null

Then when you try to ssh into host B: It first creates a ssh session to A then tunnels the traffic through netcat (nc) to host B's (%h) port 22 (%p).

share|improve this answer

What OS are you and your destination running?

If it's Linux, then the Zmodem protocol is perfect for what you are trying to do.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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