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

3

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

SshProblem

Posted 2012-10-08T13:02:56.253

Reputation: 33

Answers

4

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.

Claudius

Posted 2012-10-08T13:02:56.253

Reputation: 6 330

Works Perfectly! – SshProblem – 2012-10-08T14:10:31.240

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 – 2012-10-08T14:12:05.803

2

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

pyhimys

Posted 2012-10-08T13:02:56.253

Reputation: 121

0

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.

Daemon of Chaos

Posted 2012-10-08T13:02:56.253

Reputation: 178