被远程的windows server上装了freesshd运行ssh
客户端运行以下代码提示“Unable to execute command or shell on remote system: Failed to Execute process.”
import paramiko
def ssh2(ip,username,passwd,cmd):
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip,22,username,passwd,timeout=5)
for m in cmd:
stdin,stdout,stderr = ssh.exec_command(m)
out = stdout.readlines()
for o in out:
print o
ssh.close()
except:
print '%s\tError\n'%(ip)
if __name__ =='__main__':
cmd = ["dir"]
username = '123'
passwd = '123'
ip = '120.27.248.8'
ssh2(ip,username,passwd,cmd)
把dir改成ping之类的命令可以正常显示,dir以及一些目录的操作命令都不行,求各位大虾帮忙,谢谢
客户端运行以下代码提示“Unable to execute command or shell on remote system: Failed to Execute process.”
import paramiko
def ssh2(ip,username,passwd,cmd):
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip,22,username,passwd,timeout=5)
for m in cmd:
stdin,stdout,stderr = ssh.exec_command(m)
out = stdout.readlines()
for o in out:
print o
ssh.close()
except:
print '%s\tError\n'%(ip)
if __name__ =='__main__':
cmd = ["dir"]
username = '123'
passwd = '123'
ip = '120.27.248.8'
ssh2(ip,username,passwd,cmd)
把dir改成ping之类的命令可以正常显示,dir以及一些目录的操作命令都不行,求各位大虾帮忙,谢谢


