Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 4 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
add comment

Your Answer

 
discard

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.