def SSHConnect(host, user, passwd, port):
ssh = paramiko.SSHClient()
try:
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # any remote (~/.ssh/known_hosts)
ssh.connect(host, port = int(port),
username = user, password = passwd,
allow_agent=False, look_for_keys=False)
except:
#except paramiko.SSHException:
ssh.close()
ssh = None
print('error> failed to connect', host,
'(please check your input: ip, port, user, password)')
return ssh
评论列表
文章目录