我编写了以下程序来ssh访问运行在vmware上的Windows服务器并获取ssh日志详细信息:
import pxssh
import getpass
s = pxssh.pxssh()
hostname = '****'
username = '****'
password = getpass.getpass("Enter the password \n")
s.login (hostname,username,password)
s.sendline ('cd\;cd Program Files;type freeSSHdfreesshd.log')
s.prompt()
print s.before
当我执行上述脚本时,我收到以下错误消息:
任何人都知道要删除此错误并获得所需输出需要进行哪些更改?
答案 0 :(得分:0)
import paramiko
ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_client.connect(server, username=username,password=password)
cmd='cd\;cd Program Files;type freeSSHdfreesshd.log'
stdin, stdout, stderr =ssh_client.exec_command(cmd)
output=stdout.readlines()
print output
ssh_client.close()