[Twisted-Python] Making a Persistent SSH connection w/ Conch - How?
I'm trying to design a ssh client that establishes a connection that it persistent until I close it so that I can use it for constant bi-directional communication. I want it to act like a shell with a gui top of it (wxPython). I think I need to keep a channel open continuously to effect this. This is my first attempt at using ssh so I'm probably missing some important paradigms here, please fill me in if possible. I grabbed the the sshsimpleclient.py code from http://twistedmatrix.com/projects/conch/documentation/examples/sshsimpleclie... and modified (to test the behavior): def closed(self): print 'got data from cat: %s' % repr(self.data) #self.loseConnection() #reactor.stop() The server connection still closes as soon as I receive the callback data. I'm using freebsd and it works as advertised (I see the connection in auth.log but of course, its closed before I can 'who' and check it out) Any advice on the right way to get started would be appreciated! -John
J French wrote:
if possible. I grabbed the the sshsimpleclient.py code from http://twistedmatrix.com/projects/conch/documentation/examples/sshsimpleclie... and modified (to test the behavior):
def closed(self): print 'got data from cat: %s' % repr(self.data) #self.loseConnection() #reactor.stop()
The server connection still closes as soon as I receive the callback data. I'm using freebsd and it works as advertised (I see the
Of course it closes, that's what the client side is programmed to do. def channelOpen(self, ignoredData): self.data = '' d = self.conn.sendRequest(self, 'exec', common.NS('cat'), wantReply = 1) d.addCallback(self._cbRequest) def _cbRequest(self, ignored): self.write('hello conch\n') self.conn.sendEOF(self) Maybe sending EOF isn't the smartest move if you want to keep the thing open..
participants (2)
-
J French -
Tommi Virtanen