paramiko

paramiko 模块 linux - ssh功能

♀尐吖头ヾ 提交于 2020-02-11 09:20:19
ssh:远程执行命令,并获取返回结果import paramiko# 创建SSH对象ssh = paramiko.SSHClient()# 允许连接不在know_hosts文件中的主机ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())# 连接服务器ssh.connect(hostname='10.0.0.31', port=52113, username='root', password='123456')# 执行命令stdin, stdout, stderr = ssh.exec_command('df')# 获取命令结果res,err = stdout.read(),stderr.read()result = res if res else errprint(result.decode())# 关闭连接ssh.close() ssh:文件上传下载功能 import paramikotransport = paramiko.Transport(('10.0.0.31', 52113))transport.connect(username='root', password='123456')sftp = paramiko.SFTPClient.from_transport(transport)# 将location

Using Kerberos authentication with Paramiko

本秂侑毒 提交于 2020-02-04 07:18:04
问题 I'm struggling to figure out how to use kerberos authentication with python and paramiko. I've found the documentation for paramiko but don't know how to implement it and there seems to be a lack of tutorials specifically for kerberos and paramiko since its so new. When I ssh outside of python for normal usage, I insert a smart card and type the following from the command line in OSX Mavericks... $ kshell $ pkinit ...which then prompts me for my pin number associated with the card. From there

How do you start Python Paramiko SFTP with sudo?

半腔热情 提交于 2020-02-02 08:58:26
问题 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')

How do you start Python Paramiko SFTP with sudo?

感情迁移 提交于 2020-02-02 08:54:13
问题 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')

ImportError: No module named 'paramiko'

无人久伴 提交于 2020-02-02 00:54:12
问题 I have done through the other questions online here, and I feel that mine is different enough to warrant a new question. So I have a Centos 6 box , which is running a small website for me, acts as an office git server and I am trying to configure Python3 on it. So I followed the following these steps to set up python3 on the server. However it seems that I cannot import paramiko into my script. I downloaded the paramiko rpm however I get this message: When I try to import paramiko I get:

Recursive directory copy with Paramiko in Python

妖精的绣舞 提交于 2020-02-01 08:04:10
问题 I am new to Python scripting. I need to copy few folders from my local machine (windows) to Linux server. As of now, I am copying the folders by opening WinSCP console. I need to automate this process. I have written a below code in Python using Paramiko module library. import paramiko import os transport = paramiko.Transport(('10.10.10.10', 22)) transport.connect(username='weblogic', password='weblogic') sftp = paramiko.SFTPClient.from_transport(transport) filepath = '/apps/logs' localpath =

paramiko(基于ssh用于连接远程服务器)

别等时光非礼了梦想. 提交于 2020-01-31 01:56:53
paramiko(基于ssh用于连接远程服务器) 文章目录 paramiko(基于ssh用于连接远程服务器) 1.ssh的linux远程连接过程 2.paramiko批量远程密码连接 3.paramiko批量远程上传和下载 1.ssh的linux远程连接过程 # ssh username@ip passwd # 解决的问题:如果只前没有连接过的ip 会出现 """ [root@foundation0 .ssh]# ssh root@172.25.254.36 The authenticity of host '172.25.254.36 (172.25.254.36)' can't be established. ECDSA key fingerprint is bc:f5:f7:4b:39:41:d8:27:61:b0:56:55:e5:05:a9:5b. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '172.25.254.36' (ECDSA) to the list of known hosts. root@172.25.254.36's password: Last login: Sun Jan 12 10:16:28 2020 [root

List files on SFTP server matching wildcard in Python using Paramiko

孤街醉人 提交于 2020-01-29 16:56:05
问题 import paramiko client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect('hostname', username='test1234', password='test') path = ['/home/test/*.txt', '/home/test1/*.file', '/home/check/*.xml'] for i in path: for j in glob.glob(i): print j client.close() I am trying to list the wildcard files on remote server by using glob.glob . But glob.glob() is not working. Using Python 2.6. Remote server contains these files: /home/test1/check.file , /home

python常用模块及第三方库功能整理简介

谁说我不能喝 提交于 2020-01-28 17:06:41
前言:   Python吸引人的一个出众的优点就是它有众多的第三方库函数,可以更高效率的实现开发,经过整理与比对,整理了运维相关的常用模块,并将其功能简介,对其中重要的常用模块,接下来的博客会进行相应的详细介绍与功能使用介绍。 Python运维常用的20个库: 1、psutil是一个跨平台库(https://github.com/giampaolo/psutil) 能够实现获取系统运行的进程和系统利用率(内存,CPU,磁盘,网络等),主要用于系统监控,分析和系统资源及进程的管理。 2、IPy(http://github.com/haypo/python-ipy),辅助IP规划。 3、dnspython(http://dnspython.org)Python实现的一个DNS工具包。 4、difflib:difflib作为Python的标准模块,无需安装,作用是对比文本之间的差异。 5、filecmp:系统自带,可以实现文件,目录,遍历子目录的差异,对比功能。 6、smtplib:发送电子邮件模块 7、pycurl(http://pycurl.sourceforge.net)是一个用C语言写的libcurl Python实现,功能强大,支持的协议有:FTP,HTTP,HTTPS,TELNET等,可以理解为Linux下curl命令功能的Python封装。 8、XlsxWriter

python之day12(mysql,pymysql,SQLAchemy,paramiko)

时光怂恿深爱的人放手 提交于 2020-01-28 16:40:52
四 mysql   参考博客:http://www.cnblogs.com/wupeiqi/articles/5699254.html   权限管理:     用户管理        创建用户 create user '用户名'@'IP地址' identified by '密码'; 删除用户 drop user '用户名'@'IP地址'; 修改用户 rename user '用户名'@'IP地址'; to '新用户名'@'IP地址';; 修改密码 set password for '用户名'@'IP地址' = Password('新密码') PS:用户权限相关数据保存在mysql数据库的user表中,所以也可以直接对其进行操作(不建议)     授权:        show grants for '用户'@'IP地址' -- 查看权限 grant 权限 on 数据库.表 to '用户'@'IP地址' -- 授权 revoke 权限 on 数据库.表 from '用户'@'IP地址' -- 取消权限 all privileges 除grant外的所有权限 select 仅查权限 select,insert 查和插入权限 ... usage 无访问权限 alter 使用alter table alter routine 使用alter procedure和drop procedure