2

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

  • 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
5

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".)

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.