paramiko

Python Paramiko (Client) Multifactor Authentication

五迷三道 提交于 2019-12-06 05:32:54
问题 I'm attempting to use Paramiko (on Python 2.7) to connect to a host that uses multifactor authentication (username + password + one-time-password). The transport.auth_interactive function seems to be the way to do this (based on what I'm understanding from the documentation), but execution never reaches that point - the authentication fails on the client.connect line. I seem to be missing something. This is the code: #!/usr/bin/env python import paramiko import getpass import os import

How to use Pageant with Paramiko on Windows?

耗尽温柔 提交于 2019-12-06 04:38:56
问题 I know that Paramiko supports Pageant under Windows, but it doesn't work by default. I am looking for an example of connecting using the key that is loaded in Pageant. 回答1: This is what I am using to connect and do an automated login using Pageant to store my key, and connecting to it from within my Python script. It counts on Pageant already being loaded, (and I haven't found a good reliable way to launch it and load the key (prompt for key password)) but the below works for now. ssh =

django搭建一个小型的服务器运维网站

坚强是说给别人听的谎言 提交于 2019-12-06 02:42:50
前言   不管是运维还是开发抑或是测试,工作中不免会和Linux服务器打交道,常见的操作譬如:查看CPU或内存状态、查看和修改服务器时间、查看或者修改服务器配置文件、实时查看或回看系统的日志、重启服务器中某个进程等。如果不在服务器旁,一般会选择利用Xshell这样的远程SSH工具登陆到服务器去执行所需操作。如果有一个Web工具,该工具将会很方便的给目标用户提供服务,对于开发来说,可以更注重自己代码本身,对于运维而言可以方便直接的知道服务器的状态,对于测试人员而言,提高测试的效率。   本人在开发这个基于django的Web工具前并没有网站开发经验,都是摸着石头过河,所以在开发过程中遇到很多的问题,并且逐个解决并达成需求,其中也直接拿来一些代码复用。这些文章中会包含一些前端的技术(websocket、ajax、路由)和一些后端的小模块(paramiko、openid、webserver、MySQL),在这些小零件的拼凑中又会衍生很多小的细节和方法。此篇文章会做一个回顾,虽然很多功能有更好的实现方法,里面涉及的技术难度也不大,但是也希望能够帮助到有需求的童鞋。 内容介绍   文章默认读者已经具备了django的开发经验,文章直接略过了纷繁的初学内容,直接开始小项目,主要内容包括: 拿来即用的bootstrap模板 ; 服务器SSH服务配置与python中paramiko的使用 ;

How do you start Python Paramiko SFTP with sudo?

眉间皱痕 提交于 2019-12-06 02:21:18
Using the standard client.open_sftp() handle gives me SFTP controls but without sudo/root permissions, any sort of /etc/** files can't be edited. I have a user that has passwordless sudo access, I figured I could maybe start off with sudo su and then invoke SFTP but that did not seem to be the case. t = paramiko.Transport(('192.168.56.102', 22)) t.connect(username='vagrant', password='vagrant') chan = t.open_session() chan.get_pty() chan.invoke_subsystem('sftp') chan.exec_command('sudo su') sftp = paramiko.SFTPClient.from_transport(t) .. the error paramiko.ssh_exception.SSHException: Channel

Slow public key authentication with paramiko

不想你离开。 提交于 2019-12-06 02:16:54
I am using paramiko to connect to a remote server over ssh. When authenticating using a public key, the performance is slow (~90 secs). Here is the relevant logging output: 2012-05-14 17:37:21,378 Ciphers agreed: local=aes128-ctr, remote=aes128-ctr 2012-05-14 17:37:21,378 using kex diffie-hellman-group1-sha1; server key type ssh-rsa; cipher: local aes128-ctr, remote aes128-ctr; mac: local hmac-sha1, remote hmac-sha1; compression: local none, remote none 2012-05-14 17:37:21,481 Switch to new keys ... 2012-05-14 17:37:21,483 Adding ssh-rsa host key for 10.12.34.56:

Paramiko/cryptography deprecation warnings: CryptographyDeprecationWarning: encode_point has been deprecated on EllipticCurvePublicNumbers [duplicate]

喜你入骨 提交于 2019-12-06 01:33:54
问题 This question already has answers here : How to silence EllipticCurvePublicNumbers.encode_point CryptographyDeprecationWarning when using Paramiko in Python (2 answers) Closed 9 months ago . I keep getting the following deprecation warnings when doing simple SSH connections: 2019-03-04 02:21:14 [transport] INFO : Connected (version 2.0, client OpenSSH_7.4) /usr/local/lib/python2.7/site-packages/paramiko/kex_ecdh_nist.py:39: CryptographyDeprecationWarning: encode_point has been deprecated on

python的零碎知识

做~自己de王妃 提交于 2019-12-06 00:44:52
1.Python代码操作git 安装 pip3 install gitpython 操作git import os from git.repo import Repo # gitpython def clone(): download_path = os.path.join('codes', 'fuck') # git clone -b master https://gitee.com/wupeiqi/xxoo.git # git clone -b v1 https://gitee.com/wupeiqi/xxoo.git Repo.clone_from('https://gitee.com/wupeiqi/xxoo.git', to_path=download_path, branch='master') def pull(): # git pull origin master local_path = os.path.join('codes', 'fuck') repo = Repo(local_path) repo.git.pull() def tag_list(): local_path = os.path.join('codes', 'fuck') repo = Repo(local_path) tag_list = [item.name for item in repo

Python, paramiko, invoke_shell and ugly characters

落花浮王杯 提交于 2019-12-06 00:04:26
When I run the Python code below: import workflow import console import paramiko import time strComputer = 'server.com' strUser = 'user' strPwd = 'passwd' client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect(hostname=strComputer, username=strUser, password=strPwd) channel = client.invoke_shell() channel.send('ls\n') time.sleep(3) output=channel.recv(2024) print(output) #Close the connection client.close() print('Connection closed.') I get the desired output mixed with ugly characters: Last login: Thu Jun 19 23:37:55 2014 from 192.168.0.10 ls

How to connect to SFTP through Paramiko with SSH key - Pageant

丶灬走出姿态 提交于 2019-12-05 21:48:15
问题 I am trying to connect to an SFTP through Paramiko with a passphrase protected SSH key. I have loaded the key into Pageant (which I understand is supported by Paramiko) but I can't get it to decrypt my private key. I have found this example here that references allow_agent=True but this does not appear to be a parameter that can be used with the SFTPClient . Can anyone advise if it is possible to work with Paramiko and Pageant in this way? This is my code at the moment - which raises

Paramiko get sorted directory listing

本小妞迷上赌 提交于 2019-12-05 21:36:10
I am able to get a directory listing from Paramiko. And with listdir_attr I get the attributes. However, I need to sort this list by filename. If it returned a list of dictionaries I could use lambda to do the sort. But with it returning a list of SFTPAttributes I can't figure out how to do the sort other than creating a new list of dictionaries containing the data I care about and sorting that list. Before doing that is there a way to get a directory listing that is sorted by filename? There's no way to make SFTPClient.listdir_attr return a sorted list. Sorting is easy though: files = sftp