Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

How do I pass commands (shell) to a persistent SSH tunnel rather than open a connection for every instance? I have a Python scraper running on a client server which passes URL variables and shell commands to a remote host via a reverse tunnel (forwarded port), so that the URL's are then executed on the host (python > fabric > ssh localhost:12345 'browser open URL'). I could make the reverse tunnel persistent but how do I echo the url/command to the session?

Update - ControlMaster (built into SSH) solves this one.

share|improve this question
    
when you say 'commands' do you mean shell commands, or is the command itself the URL in question (eg: its just data)? are you connecting to a server-side service using ssh as your carrier, or are you just executing shell commands as part of an ssh session? – Frank Thomas Nov 30 '12 at 3:52
    
I found what I was looking for, for now (see below). In response it's a shell command, sent to the host through SSH, in this example ssh -p 00000 localhost 'DISPLAY=:0.0 firefox %s' %URL. I'm still learning to walk and I don't think using SSH will be the best way as things get heavier so any suggestions are appreciated. But for now this works and saves messing about with queues. – woowaa Nov 30 '12 at 4:47

I just discovered ControlMaster which is built into later SSH versions and reuses existing connections if they exist:

http://www.revsys.com/writings/quicktips/ssh-faster-connections.html

Great stuff. I might look into proxies and what not when things get a bit heavier so any advice on developing this is appreciated.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .