paramiko

Ansible的安装及常用模块

六月ゝ 毕业季﹏ 提交于 2021-02-12 03:41:02
简介 Ansible 基于 Python 语言实现,由 Paramiko 和 PyYAML 两个关键模块构建。 Ansible 特点: 1、部署简单,只需在主控端部署 Ansible 环境,被控端无需做任何操作。 2、默认使用 SSH(Secure Shell)协议对设备进行管理。 3、主从集中化管理。 4、配置简单、功能强大、扩展性强。 5、支持 API 及自定义模块,可通过 Python 轻松扩展。 6、通过 Playbooks 来定制强大的配置、状态管理。 7、对云计算平台、大数据都有很好的支持。 8、提供一个功能强大、操作性强的 Web 管理界面和 REST API 接口 —- AWX 平台。 Ansible 与 SaltStack: 1、最大的区别是 Ansible 无需在被监控主机部署任何客户端代理,默认通过 SSH 通道进行远程命令执行或下发配置。 2、相同点是都具备功能强大、灵活的系统管理、状态配置,都使用 YAML 格式来描述配置,两者都提供丰富的模板及 API,对云计算平台、大数据都有很好的支持。 安装ansible yum安装 yum -y install ansible 配置ansible tree /etc/ansible/ /etc/ansible/ ├── ansible.cfg # ansible.cfg 是 Ansible 工具的配置文件; ├──

Passwordless SSH using paramiko

吃可爱长大的小学妹 提交于 2021-02-09 00:46:04
问题 Issue : I'm a noob with Paramiko, trying to run some commands from a python script (on personal machine) on a remote server. The remote server doesn't need a password to connect to. For example, if I do root@[IPaddress] on my Mac, I'm successfully able to connect to the remote server via MacbookPro terminal. However, I'm trying to do this inside a Python script using Paramiko, and no matter what I do, I get an Authentication error or No Authentication methods available. I went through

python multiprocessing paramiko ssh connections

烂漫一生 提交于 2021-02-08 09:55:48
问题 I am writing a script to connect to a bunch of cisco routers and run commands on them, hosts and commands are put into a text file and then read from the script. Below is the code i got, when i don't use the pool.map everything works good, but when trying to use the pool.map to spawn more process, i keep getting errors. #!/usr/bin/python #Import modules from multiprocessing.pool import ThreadPool import sys, os import paramiko import time import getpass import socket def unpack_call(callable

python multiprocessing paramiko ssh connections

不羁岁月 提交于 2021-02-08 09:53:01
问题 I am writing a script to connect to a bunch of cisco routers and run commands on them, hosts and commands are put into a text file and then read from the script. Below is the code i got, when i don't use the pool.map everything works good, but when trying to use the pool.map to spawn more process, i keep getting errors. #!/usr/bin/python #Import modules from multiprocessing.pool import ThreadPool import sys, os import paramiko import time import getpass import socket def unpack_call(callable

Setup SSH tunnel with Paramiko to access PostgreSQL

笑着哭i 提交于 2021-02-08 09:14:12
问题 I currently use Paramiko to access an SFTP server and connect to the PostgreSQL on the same server. I found many examples using sshtunnel to log on PostgreSQL. But I don't know how to do it with pure Paramiko. Currently my code looks something like: # establish SSH tunnel self.ssh = paramiko.SSHClient() self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self.ssh.connect(hostname=host, username=user, password=password) # setup SFTP server self.sftp = self.ssh.open_sftp() # connect

pysftp.CnOpts() 'No Host Keys Found' error despite known_hosts file generated using ssh-keyscan

让人想犯罪 __ 提交于 2021-02-08 08:52:26
问题 I am trying to follow solution from Verify host key with pysftp. I run: import pysftp fn = r'C:\Users\UWAdmin\.ssh\known_hosts' cnopts = pysftp.CnOpts() cnopts.hostkeys.load(fn) but I get the error: HostKeysException Traceback (most recent call last) <ipython-input-3-b5b4d53fef6c> in <module> ----> 9 cnopts = pysftp.CnOpts() 10 cnopts.hostkeys.load(fn) ~\miniconda3\envs\pycontrol\lib\site-packages\pysftp\__init__.py in __init__(self, knownhosts) 62 else: 63 if len(self.hostkeys.items()) == 0:

Loading key from an SSH jumphost using Paramiko

梦想的初衷 提交于 2021-02-08 07:22:11
问题 I am connecting from host1 to host3 using a middle host2. host1 --> host2 --> host3 Here is my code that is working fine: # SSH to host2 ssh = paramiko.SSHClient() ssh.load_system_host_keys() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(host2, username=host2_username) # SSH to host3 vmtransport = ssh.get_transport() dest_addr = (host3, 22) local_addr = (host2, 22) vmchannel = vmtransport.open_channel("direct-tcpip", dest_addr=dest_addr, src_addr=local_addr) ssh3 =

Loading key from an SSH jumphost using Paramiko

感情迁移 提交于 2021-02-08 07:20:44
问题 I am connecting from host1 to host3 using a middle host2. host1 --> host2 --> host3 Here is my code that is working fine: # SSH to host2 ssh = paramiko.SSHClient() ssh.load_system_host_keys() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(host2, username=host2_username) # SSH to host3 vmtransport = ssh.get_transport() dest_addr = (host3, 22) local_addr = (host2, 22) vmchannel = vmtransport.open_channel("direct-tcpip", dest_addr=dest_addr, src_addr=local_addr) ssh3 =

Opening Astropy FITS file from SFTP server

孤人 提交于 2021-02-08 03:30:23
问题 I have a Python script that ssh into a remote server using Paramiko module. The below is my script import paramiko ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect("host", username="McMissile") A FITS file on a local machine is usually opened as follows: from astropy.io import fits hdu = fits.open('File.fits') I was wondering how would I open a FITS file from the SFTP server machine and store it under the variable hdu in the local machine. I

With pysftp or Paramiko, how can I get a directory listing complete with attributes?

允我心安 提交于 2021-02-08 02:17:52
问题 As the title says, I'm trying to get a list of all the files and directories in a directory, including their attributes (I'm looking for at least name, size, last modified, and is it a file or a folder). I'm using Python 3 on Windows. I've tried listdir() , and I get a list of files without attributes. I've tried listdir_attr() , and I get a list of attributes, but no filenames - and I don't see anything that guarantees that those two lists will be in the same order, so as far as I know, I