Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a machine which I cannot ssh into. I would like to be able to have controll a shell session in it. Is there some way to have it connect out to another machine and for me to issue commands on the server machine that are ran on the client machine?

share|improve this question
What can you do on that machine? Can you run web-based scripts such as PERL, Python or PHP? Also, are you allowed to run long-running apps or just web-scripts? – Julian Knight Aug 3 '12 at 21:15
up vote 3 down vote accepted

You can if you're able to set up a reverse ssh session.

Use the following to set up the reverse port forwarding on the machine you can't access (i.e. you have to do this once on that machine)

ssh -R 2210:localhost:22

and then whenever you want from your home machine:

ssh -p 2210 localhost

will connect to the machine you couldn't access.

See here for more information.

share|improve this answer
I suspect that, if he cannot get SSH access, he won't be able to set up a reverse SSH session. – Julian Knight Aug 3 '12 at 21:20
Actually the reverse SSH sessions are perfect for cases where SSH access is not possible - check the link in my answer. Not being able to SSH doesn't imply that the OP can't access the unreachable machine at all - it could be blocked by a firewall. – jmetz Aug 3 '12 at 21:23
I see your point, my answer was thinking of a hosted server where you only have limited access. Though, in reality in your scenario it is very unlikely that any ports other than the standard HTTP ones are left open even for outbound. I have used a port 443->22 PAT mapping for this in the past. It is also increasingly common for outbound filters to check for odd traffic and block this kind of connection anyway - all of the big suppliers have this kind of filtering available now (e.g. CISCO). – Julian Knight Aug 3 '12 at 21:50
This is exactly what I was looking for! Thank you! – Tony Aug 4 '12 at 0:48

If you can run web application scripts on the machine, I would recommend setting up a secure set of scripts that are triggered via HTTPS - perhaps from a custom menu. Most scripting languages including PHP, Python and PERL, Lua, Ruby, etc. are able to run OS level commands.

Indeed, this is how Webmin works - except it goes even further. It creates it's own web server.

I've done this in the past to deal with the issue you highlight.

You can also go further if you can get the machine to talk to a mail server - I would generally set aside an IMAP mail account. Then you can set up a script that checks the mailbox for specifically formatted emails periodically.

share|improve this answer
Thanks for the response. I should have explained more clearly my situation in my original question—mutzmatron gave the response I was really looking for. – Tony Aug 4 '12 at 0:49
Not a problem, glad you found the answer you needed. – Julian Knight Aug 4 '12 at 8:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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