jjzjj

paramiko

全部标签

python - Paramiko AuthenticationException 问题

我在使用Paramiko(版本1.7.6-2)ssh客户端连接到设备时遇到问题:$pythonPython2.6.5(r265:79063,Apr162010,13:09:56)[GCC4.4.3]onlinux2Type"help","copyright","credits"or"license"formoreinformation.>>>importparamiko>>>ssh=paramiko.SSHClient()>>>ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())>>>ssh.connect("123.0.0

Python paramiko 脚本,在 exec_command() 期间读取输出时出现问题

背景:我正在使用python和paramiko来自动化我每次必须为类(class)提交程序时所经历的过程。我们使用名为“handin”的命令来提交源代码,但这必须在学校计算机上完成。所以当我从家里提交代码时,我必须:sftp进入学校服务器,将文件放在目录中,ssh进入学校计算机,使用'handin'命令我可以成功地将文件放到学校的机器上。当我尝试使用exec_command('handinmyfiles')然后读取输出以确定下一步操作时出现问题。所以我有try:(stdin,stdout,stderr)=client.exec_command(s)except:print'whoops

python - paramiko 结合 stdout 和 stderr

我正在尝试合并stdout和stderr的输出。我相信这可以通过Channel对象的set_combine_stderr()来完成。这就是我正在做的:SSH=paramiko.SSHClient()#IconnectandeverythingOK,then:chan=ssh.invoke_shell()chan.set_combine_stderr(True)chan.exec_command('python2.6subir.py')resultado=chan.makefile('rb',-1.)但是,当我尝试存储结果时出现以下错误(上面最后一行,chan.makefile()):E

python - 如何在没有密码的情况下使用 paramiko 连接到远程服务器?

我正在用Python编写脚本,它需要使用SSH连接到remote_server并将file从remote_server移动到主机服务器。我需要在没有密码的情况下执行此操作,因为它需要适用于任何远程服务器和任何主机服务器用户。我的代码:#getIPandusernameforremoteaccessIP=input("Enterhost_serverIP:").split()username=input("Enterusername:").split()#password=???????#createafileonhost_serverforfilefile_a=open(date+"f

python - Paramiko 和 exec_command - 杀死远程进程?

我正在使用Paramikotail-f远程服务器上的文件。以前,我们通过ssh-t运行它,但事实证明这很不稳定,-t导致我们的远程调度系统出现问题。我的问题是当脚本捕获到SIGINT时如何终止tail?我的脚本(基于Long-runningsshcommandsinpythonparamikomodule(andhowtoendthem))#!/usr/bin/envpython2importparamikoimportselectclient=paramiko.SSHClient()client.load_system_host_keys()client.connect('somes

python - 使用 Paramiko 在 Python 中通过 ssh 实现交互式 shell?

我想编写一个程序(在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 连接中将文件传输到 ssh 服务器?

我正在使用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 - Paramiko 无法下载大于 1GB 的大文件

defdownload():ifos.path.exists(dst_dir_path)==False:logger.error("Cannotaccessdestinationfolder%s.Pleasecheckpathandpermissions."%(dst_dir_path))return1elifos.path.isdir(dst_dir_path)==False:logger.error("%sisnotafolder.Pleasecheckpath."%(dst_dir_path))return1file_list=None#transport=paramiko.Tr

python - 如何使用 Paramiko 运行 sudo? (Python)

我尝试过的:invoke_shell()然后channel.sendsu然后发送密码导致不是rootinvoke_shell()然后channel.exec_command导致了“ChannelClosed”错误_transport.open_session()然后channel.exec_command导致不是rootinvoke_shell()然后写入stdin并刷新它导致不是root 最佳答案 检查这个例子:ssh.connect('127.0.0.1',username='jesse',password='lol')stdi

python paramiko ssh

我是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