def __init__(self, host, port, username, password, key=None, passphrase=None):
self.username = username
self.password = password
self.ssh = paramiko.SSHClient()
# ssh.load_system_host_keys()
self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# ssh.set_missing_host_key_policy(paramiko.WarningPolicy())
if key is not None:
key = paramiko.RSAKey.from_private_key(StringIO(key), password=passphrase)
self.ssh.connect(host, port, username=username, password=password, pkey=key, timeout=self.TIMEOUT)
评论列表
文章目录