[Twisted-Python] Twisted Conch SSH timeout

Paul Swartz paulswartz at gmail.com
Wed Feb 4 22:50:20 EST 2009


On Wed, Feb 4, 2009 at 11:49 AM, ray terrill <rayjohnterrill at gmail.com> wrote:
> Could you give me an example of how handling the connectionLost() could be
> accomplished?  I'm not sure where I need to integrate that into what I've
> already got.

For example:

class ClientCommandTransport(
transport.SSHClientTransport):
   def __init__(self, username, password, command):
      self.username = username
      self.password = password
      self.command = command

   def verifyHostKey(self, pubKey, fingerprint):
      # in a real app, you should verify that the fingerprint matches
      # the one you expected to get from this server
      return defer.succeed(True)

   def connectionSecure(self):
      self.requestService(
         PasswordAuth(self.username, self.password,
            ClientConnection(self.command)))

    def connectionLost(self, reason):
        print 'do something because the connection went away'

HTH,
-p
-- 
Paul Swartz
paulswartz at gmail dot com
http://paulswartz.net/
AIM: z3penguin




More information about the Twisted-Python mailing list