def sshclient_execmd_ps(hostname,execmd,port=port, username=username, password=password):
paramiko.util.log_to_file("paramiko.log")
s = paramiko.SSHClient()
s.set_missing_host_key_policy(paramiko.AutoAddPolicy())
s.connect(hostname=hostname, port=port, username=username, password=password)
stdin, stdout, stderr = s.exec_command (execmd)
stdin.write("Y") # Generally speaking, the first connection, need a simple interaction.
out = stdout.read()
print out
s.close()
return out
评论列表
文章目录