python ssh实时交互 python udp可以远程执行cmd命令吗?

python udp可以远程执行cmd命令吗?你可以使用python的pexcpct包通过ssh调用远程服务器指令:import pxsshimport getpasstry:s = pxssh.px

python udp可以远程执行cmd命令吗?

你可以使用python的pexcpct包通过ssh调用远程服务器指令:

import pxssh

import getpass

try:

s = pxssh.pxssh()

hostname = raw_input("hostname: ")

username = raw_input("username: ")

password = getpass.getpass("password: ")

s.login (hostname, username, password)

s.sendline ("uptime") # run a command

s.prompt() # match the prompt

print s.before # print everything before the propt.

s.sendline ("ls -l")

s.prompt()

print s.before

s.sendline ("df")

s.prompt()

print s.before

s.logout()

except pxssh.ExceptionPxssh, e:

print "pxssh failed on login."

print str(e)

如何使用Python连接远程Windows服务器?

你可以在winodws 上架设ssh 服务器, 然后你就可以在本地通过ssh协议来连接服务器,然后选择程序. python 的ssh 模块可以使用paramiko