我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用paramiko.ssh_exception()。
def __init__(self, context): self.context = context self.connection_attempts = 20 self.transport = None self.client = paramiko.SSHClient() self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) for tries in range(self.connection_attempts): try: self.client.connect(hostname=self.context.hostname, username=self.context.username, port=self.context.port, allow_agent=True, look_for_keys=True) break except paramiko.ssh_exception.AuthenticationException, paramiko.ssh_exception.SSHException: LOG.warning("Unable to authenticate with remote server") raise bastion_ssh.errors.ConnectionError( "Unable to authenticate with remote server") except (socket.error, EOFError): LOG.warning("connection refused. retrying.") time.sleep(tries + 1)