我一直在寻找一个模块,它允许我在python中执行SSH/SFTP功能,而无需使用POPEN手动执行。有这样的东西吗?我还没有找到这方面的任何真实信息,谢谢! 最佳答案 您可能正在寻找出色的paramiko库:http://www.paramiko.org/ 关于PythonSSH/SFTP模块?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/1603984/
我有一个扭曲的应用程序,现在需要监视在多个机器上运行的进程。我手动执行的方式是“ssh和ps”,现在我想让我的扭曲应用程序执行。我有2个选择。使用paramiko或利用twisted.conch的力量我真的很想使用twisted.conch但我的研究让我相信它主要是为了创建SSHServers和SSHClients。但是我的要求是一个简单的remoteExecute(some_cmd)我能够弄清楚如何使用paramiko执行此操作,但我不想在了解如何使用执行此操作之前将paramiko粘贴到我的扭曲应用>twisted.conch使用twisted的关于如何使用ssh运行remote_
我正在使用带有远程解释器的pycharm。当我尝试使用matplotlib时出现以下错误:>>>importmatplotlib.pyplotaspltBackendTkAggisinteractivebackend.Turninginteractivemodeon.FailedtoenableGUIeventloopintegrationfor'tk'Traceback(mostrecentcalllast):File"/home/donbeo/.pycharm_helpers/pydev/pydev_console_utils.py",line498,indo_enable_gui
这与此有关question在这里,但有一点点变化:我需要Fabric将任意字符串传递到远程shell,而不是仅仅传递"is"或“否”。例如,如果远程shell提示“你叫什么名字?”然后我需要“先,后”喂它。澄清:我知道我说的是任意输入,但我真的是tryingtouseitfortheSSHkeypasswdpromptwhenItrytodoagitpull.更新#1:得到JeffForcier@bitprophet的回复that’slikethe#1wartrightnow:(Eithertunnellingtosendakeyagentout-of-band,orremotepro
我想编写一个程序(在Windows7上的Python3.x中)通过ssh在远程shell上执行多个命令。在查看paramikos的exec_command()函数后,我意识到它不适合我的用例(因为channel在命令执行后关闭),因为命令取决于环境变量(由先前设置命令)并且不能串联成一个exec_command()调用,因为它们将在程序的不同时间执行。因此,我想在同一个channel中执行命令。我研究的下一个选项是使用paramikos的invoke_shell()函数实现交互式shell:ssh=paramiko.SSHClient()ssh.set_missing_host_key
我正在使用Python的paramiko数据包来保持与服务器的ssh连接:s=paramiko.SSHClient()s.set_missing_host_key_policy(paramiko.AutoAddPolicy())s.connect("xxx.xxx.xxx.xxx",22,username=xxx,password='',timeout=4)我想使用这个ssh连接来传输文件到ssh服务器,我该怎么做?就像使用scpa-filexxx@xxx.xxx.xxx.xxx:文件路径命令? 最佳答案 试试这个:s=parami
我需要一个Python程序来轮询远程服务器的SSH连接并在它可用时发出通知。我目前正在使用paramiko进行此操作;尝试连接,如果失败,请等待并重试,直到成功或最大重试次数。这可行,但有点笨拙。paramiko似乎也连接或抛出错误,所以我能看到这样做的唯一方法是使用try/exceptblock,这是坏的,坏的,坏的。方法如下:defcheck_ssh(self,ip,user,key_file,initial_wait=0,interval=0,retries=1):ssh=paramiko.SSHClient()ssh.set_missing_host_key_policy(pa
我是python的新手。我写了一个脚本来连接到主机并执行一个命令ssh=paramiko.SSHClient()ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())ssh.connect(host,username=user,password=pw)print'runningremotecommand'stdin,stdout,stderr=ssh.exec_command(command)stdin.close()forlineinstdout.read().splitlines():print'%s$:%s'%(host
如何向Popen()对象中的多个ssh-t进程发送Ctrl-C?我有一些Python代码可以启动远程主机上的脚本:#kickoff.py#icall'ssh'w/the'-t'flagsothatwhenipress'ctrl-c',itget's#senttothescriptontheremotehost.otherwise'ctrol-c'wouldjust#killthingsonthisend,andthescriptwouldstillberunningonthe#remoteservera=subprocess.Popen(['ssh','-t','remote-host
我正在使用paramiko在远程机器上通过ssh执行一个长时间运行的python脚本。工作起来很有魅力,到目前为止没有问题。不幸的是,stdout(分别为stderr)仅在脚本完成后显示!但是,由于执行时间的原因,我更愿意在打印时输出每一行,而不是事后输出。remote=paramiko.SSHClient()remote.set_missing_host_key_policy(paramiko.AutoAddPolicy())remote.connect("host",username="uname",password="pwd")#myScriptproducescontinuou