I am using the following command to setup an SSH tunnel to a remote server. I am using Ubuntu 15.10, and the remote server is running Ubuntu 14.04.3.

ssh -N -f -L localhost:7154:localhost:7154 username@server -p 9999

When executing the command, it asks me for the remote server password, and then it works just fine. However, I am wanting to use autossh so that I can keep the connection alive. I tried:

autossh -M 20000 -f -N -L localhost:7154:localhost:7154 username@server -p 9999

But I do not get a password prompt. The command just executes, and the tunnel isn't setup properly.

Any suggestions on how to get this to work?

  • Please edit your question and include the OS of both local and remote machine. Also, please don't tag with an OS tag unless the question is only applicable to that OS. – terdon Feb 16 '16 at 17:59
  • 2
    Rather than using a third-party-tool for this, why not use ssh's own built-in functionality for this from the ControlMaster, ControlPersist, ControlPath configuration settings? – DopeGhoti Feb 16 '16 at 18:01
  • I wasn't aware of those options, thank you! – user1566200 Feb 16 '16 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.