def get_client(cls, host, user, debug=False):
key = (host, user)
if key not in cls.clients:
client = SSHClient()
client.load_system_host_keys()
client.set_missing_host_key_policy(AutoAddPolicy())
client.connect(host, username=user)
cls.clients[key] = client
if debug:
printer.debug('Created SSH connection for {user}@{host}'.format_map(locals()))
else:
printer.debug('Using existing SSH connection for {user}@{host}'.format_map(locals()))
return cls.clients[key]
评论列表
文章目录