def ssh(config, host):
"""
Check that a host is running SSH
:param config: Unused
:param host: The host to check
:return: 3-tuple of (success, name, message)
success: Boolean value indicating if there is a problem or not
name: DNS name
message: String describing the status
"""
del config
name = host
try:
ssh_conn = paramiko.SSHClient()
ssh_conn.set_missing_host_key_policy(
paramiko.client.MissingHostKeyPolicy())
ssh_conn.connect(host)
return True
except (paramiko.BadHostKeyException, paramiko.AuthenticationException,
paramiko.SSHException, socket.error) as e:
return (False, name, "Unable to SSH to %s %s %s"
% (host, e.__class__, e))
评论列表
文章目录