In order to access a particular linux machine, I must first ssh to a provided gateway server, however I never receive a command line on the gateway server. Immediately on login to the gateway I am prompted for the name of the desired destination machine behind the gateway (there are several) and if I provide a valid machine name I'm then prompted for my username for the requested machine behind the gateway and then I'm directly dumped into a command line on the requested machine behind the gateway.

Is it possible to set up passwordless ssh login in such a scenario from my client machine to the destination machine behind the gateway?

What about cloning repositories via ssh to the the destination machine behind the gateway? I can scp directly to a filesystem mounted on the destination machine via the gateway machine (gw.foobar.com) like so:

scp foo.txt myusername@gw.foobar.com:/home/myusername

However if I try

hg clone myrepository ssh://myusername@gw.foobar.com//home/myusername

I get prompted for my password for the gateway and then:

sshgate: Invalid command (Session type) 'HG'
abort: could not create remote repo!

  • 1
    From what you explain, it does not look like any standard solution. – Jakuje May 11 '16 at 14:58

Does the gateway permit you to use the port forwarding at all? What happens if you do ssh gateway -v -W internalhost:22. If that command works then it is easy. Just use it as a proxy command. The lack of an interactive shell on your gateway doesn't necessarily mean that port forwarding is disabled. The port forwarding happens at the SSH protocol level, and doesn't depend on whatever shell is launched at login at all.

In your .ssh/config

Host farhost
  ProxyCommand ssh gatewayhost -W internalhost:22

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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