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'm looking for a way to easily send commands back to my local computer, while connected to a remote host via ssh. Is this doable via tunnelling? Both systems are UNIXen.

For instance, I am connected to a remote host and through some alias "backwards" I want to do:

user@remote $ backwards echo hi

And the local machine would execute echo hi

share|improve this question
Are you on a Unix system? – Paul Aug 13 '11 at 19:51
Yes, I am. Both ends in fact. – Sarah Aug 13 '11 at 19:53
up vote 5 down vote accepted

Standard SSH implementations do not provide this functionality. You will have to connect back to your local computer:

remote$ ssh "${SSH_CONNECTION%% *}" echo hi

If you are behind a NAT, you can use SSH "remote forwarding" to make the connection:

local$ ssh -R 23456:localhost:22 remote
remote$ ssh -P 23456 localhost echo hi

(With -R, "localhost:22" is the client's "localhost".)

share|improve this answer

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.