There are three machines A, B and C running linux. I have root access to machines A and B but not to C. A is my local machine and I want to connect to C. C is only reachable through ssh over VPN. I can not connect directly from A to C because VPN traffic is blocked in A. I can connect from A to B through ssh using shared keys. I'm running openvpn in B and then I can connect to C through ssh but C does not accept shared keys. I want to scp files directly and passwordless from C to A and from A to C so I created an ssh master connection in B and an ssh tunnel in A. However I can not make the tunnel to use the master connection in B. My question is how can I setup ssh in order to connect from A to C using the existing master connection in B?
closed as off-topic by Falcon Momot, Andrew Schulman, MadHatter, Sven♦, mdpc Nov 28 '14 at 4:20
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions must be relevant to professional system administration. Server Fault is dedicated to professional system and network administrators. End user and enthusiast questions are off-topic (contact your system administrator or hire a professional to help you out). Please see the Help Center for more information." – Andrew Schulman, MadHatter, Sven, mdpc
I can see three ways to achieve this:
1. You can run scp on A and instead of having it just ssh to another host and run scp there, you have it ssh to B and on B run another ssh command to connect to C and run the server side scp there.
It appears scp does not have an option to specify how to invoke scp on the remote side, however it does have an option to specify how to invoke ssh locally. That is the
-S option intended to tell it where to find
What you can do is to run scp with the
-S option pointing to a script. That script will then ssh to B and run ssh there, the ssh command on B will have to be invoked with all the options that scp on A gave to the script.
2. If you can manage to configure an authorized_keys file on C, you can have A authenticate directly towards C. It might be that all you are missing is proper permissions on the authorized_keys file on C. Since A cannot connect directly to C, you will instead specify a ProxyCommand that will run
ssh -W to connect from A to B. Sounds like in your case that needs to go in
~/.ssh/config on A. The value to use would be
ssh -W %h:%p B
3. Run the scp command on C and have C connect back to A. If C cannot connect directly to A, then the connection can instead be opened either by using ProxyCommand as suggested above or by setting up an ssh reverse port forwarding between A and B or between B and C.