'When the underlying connection to the SSH server is lost, if there were
any connection setup errors, propagate them. Also, clean up the
connection to the ssh agent if one was created.'

def connectionLost(self, reason):

    if self._userauth:
        self._userauth.loseAgentConnection()
    if ((self._state == 'RUNNING') or (self.connectionReady is None)):
        return
    if ((self._state == 'SECURING') and (self._hostKeyFailure is not None)):
        reason = self._hostKeyFailure
    elif (self._state == 'AUTHENTICATING'):
        reason = Failure(AuthenticationFailed('Connection    lost    while    authenticating'))
    self.connectionReady.errback(reason)
