任何人都可以推荐一些在 python 中建立 ssh 连接的东西吗?
我需要它与任何操作系统兼容。
我已经尝试过 pyssh 只是为了得到 SIGCHLD 错误,我读过这是因为 Windows 缺少这个。
我尝试过让 paramiko 工作,但 paramiko 和 Crypto 之间存在错误,以至于每个最新版本都无法一起工作。
Python 2.6.1 当前在 Windows 计算机上。
请注意这在 Windows 中不起作用.
模块 pxssh 正是您想要的:
例如,要运行“ls -l”并打印输出,您需要执行类似的操作:
from pexpect import pxssh
s = pxssh.pxssh()
if not s.login ('localhost', 'myusername', 'mypassword'):
print "SSH session failed on login."
print str(s)
else:
print "SSH session login successful"
s.sendline ('ls -l')
s.prompt() # match the prompt
print s.before # print everything before the prompt.
s.logout()
一些链接:
Pxssh 文档:http://dsnra.jpl.nasa.gov/software/Python/site-packages/Contrib/pxssh.html
Pexpect(pxssh 基于 pexpect):http://pexpect.readthedocs.io/en/stable/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)