Assume that I have an ssh tunnel running in the background, e.g.:

ssh -L 1478:localhost:1478 admin@m1 -N

And I want to connect to m1, however, in the time between starting the tunnel and now, I've lost the ability to ssh into the machine (the tunnel, however, is still working).

Is there a way to use the existing tunnel to ssh into the machine (as in, open a console that sends commands to that machine as the user admin).

I know this would be trivial if I opened the tunnel without the -N argument, but I'm unsure if it can be done when opening tunnels this way.


If by lost the ability to ssh, you meant lost access to credentials, like expired ssh-agent identities or rm -rf-ed private keys, then yes you can still log-in to the host, iff tunnel's ssh connection was opened with ControlMaster option. The ControlMaster option let you reuse existing SSH master session socket without re-authenticating for every new session you want to open.


  • The ControlMaster option wasn't set at the time of opening the tunnels.
    – George
    May 14 '18 at 13:26
  • I'm sorry I don't know of any other mechanism that could prevent authentication and still provide you with access to the host, assuming that's the intent.
    – abbe
    May 14 '18 at 13:32
  • That is the intent, thanks for the suggestion anyway.
    – George
    May 14 '18 at 13:34

Your Answer

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

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