paramiko

Paramiko Protocol error: expected packet SSH_MSG_USERAUTH_REQUEST, got SSH_MSG_SERVICE_REQUEST

对着背影说爱祢 提交于 2019-11-29 15:20:07
When I use ssh command to manually connect to the host, everything works fine: $ ssh -v admin@mycli.abc.com -p 10000 OpenSSH_6.1p1, OpenSSL 1.0.1c 10 May 2012 debug1: Reading configuration data /home/todd/.ssh/config debug1: Reading configuration data /etc/ssh/ssh_config debug1: Connecting to mycli.abc.com [mycli.abc.com] port 10000. debug1: Connection established. debug1: identity file /home/todd/.ssh/id_rsa type 1 debug1: identity file /home/todd/.ssh/id_rsa-cert type -1 debug1: identity file /home/todd/.ssh/id_dsa type -1 debug1: identity file /home/todd/.ssh/id_dsa-cert type -1 debug1:

Execute command/script using different shell in SSH/Paramiko

浪尽此生 提交于 2019-11-29 12:34:54
I am rather new to Linux and Paramiko, but the issue I am having is anytime I attempt to change a shell the remote Paramiko session will hang. The remote host is in /etc/csh by default I am running various scripts, some require csh and others require bash . Any of my scripts running in csh work properly since the remote host is in csh by default. To run the other scripts I need to be in bash . Whenever I attempt to change the shell using bash or /bin/bash paramiko connection will simply hang. I am using the following command to verify shells prior to connection and after attempting to

paramiko: SSH port forwarding to get SQL dump

一世执手 提交于 2019-11-29 11:41:29
I am trying to use a python script to get an SQL dump from a remote host, with an intermediate host as proxy, like so: local machine -> proxy -> remote The proxy needs to be there because the remote host only allows connections through that proxy. Note: I am aware of a similar question at How to connect to a database through a Paramiko Tunnel (or similar package) but the solution seems to be specific to PostgreSQL. I am making the connection using SSH via paramiko. I am aware that forward.py is the paramiko example for port forwarding, but I am not sure if I am using it correctly. This is what

python, paramiko, ssh exception ssh session not active

倖福魔咒の 提交于 2019-11-29 11:09:53
I'm working on a python script that goes to each switch in our network, and issues a copy running-config TFTP command, that backs up the running configuration of the switch. I'm on windows and utilizing the paramiko library in Python 2.7. The script itself is pretty simple, all it does is create a directory called "Backups" if one doesn't exist already, and another directory named today's date, and then uses that directory for the TFTP. And it starts up the TFTP Server. Then it simply issues the copy command via ssh. This issue I am trying to overcome is during connectSwitch(). Specifically on

How to silence EllipticCurvePublicNumbers.encode_point CryptographyDeprecationWarning when using Paramiko in Python

守給你的承諾、 提交于 2019-11-29 10:36:12
CryptographyDeprecationWarning: encode_point has been deprecated on EllipticCurvePublicNumbers and will be removed in a future version. Please use EllipticCurvePublicKey.public_bytes to obtain both compressed and uncompressed point encoding. This has been fixed in Paramiko 2.5.0 already: https://www.paramiko.org/changelog.html#2.5.0 https://github.com/paramiko/paramiko/pull/1379 https://github.com/paramiko/paramiko/issues/1369 I've had better success with: import warnings warnings.simplefilter("ignore", cryptography.utils.DeprecatedIn23) 来源: https://stackoverflow.com/questions/54861026/how-to

SSH module for python

喜欢而已 提交于 2019-11-29 10:03:36
问题 I have to do a job (using my web server) on a remote machine that takes about 10 minutes. I have used pxssh module in python for the same but it gives me "timeout error"(non blocking). Now, I am using paramiko but that comes back as soon as it gives the instruction. I want the web server to wait till the job is complete. Is there any python SSH module available for this. Or Can we achieve the same by changing any configuration settings of pxssh or paramiko ? 回答1: You can use the recv_exit

python实现ssh远程连接,以及文件的传送

拥有回忆 提交于 2019-11-29 09:58:56
一、使用工具 win7 , pycharm , python2.7.14, pip 19.2.3 二、测试过程 将 DUT (待测物)接入网络中,然后远程操作 DUT ,使用 SSH 远程登录到主机,然后执行相应的 command 即可。 三、使用到的库 paramiko ( python 中的一个库) 四、模块简介 遵循 SSH2 协议,支持以加密和认证的方式,进行远程服务器的连接。 首先安装 paramiko 这个包 五、模块连接使用接口 安装命令: pip install paramiko 导入 paramiko 连接方法: paramiko.SSHClient() 执行方法: exec_command() 断开连接: close () 信息传输: Transport (待定) 六、输入 Ip : 10.65.150.171 密码: ns0fucs123 用户名: root 命令: ls (罗列出 DUT 下面拥有的目录结构) 输出:相应的命令所应该输出的东西 linux下面的目录输出出来 验证: 七、文件的传输 八、风险分析: 这个脚本可能写不出来,这个库目前网上只是给出了连接的过程。但是还没有关于文件的传输的说明,还需要进一步的调研工作。现在只是将这个里面的连接整明白了。连接下面的东西还不是特别的明白。以及连接中文件的传递还不是特别的清楚。 九、附件: 连接的部分代码展示

Persistent ssh session to Cisco router

蹲街弑〆低调 提交于 2019-11-29 09:24:10
问题 I have search on this site and multiple other locations but I have been unable to resolve my problem of connecting and maintaining ssh session after one command. Below is my current code: #!/opt/local/bin/python import os import pexpect import paramiko import hashlib import StringIO while True: cisco_cmd = raw_input("Enter cisco router cmd:") ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect('192.168.221.235', username='nuts', password='cisco',

How to connect to a database through a Paramiko Tunnel (or similar package)

半城伤御伤魂 提交于 2019-11-29 09:01:20
I am having serious issues setting up a proper tunnel in paramiko to enable a database connection. I have reviewed the example 'forward.py', but am not understanding how to then link the database connection to it. Any pointers woudl be much appreciated. I think I need something the following: t = paramiko.Transport((hostname, port)) t.connect(username=username, password=password, hostkey=hostkey) c = paramiko.Channel(t) #something about assigning a local port to this connection connection = psycopg2.connect(connectionstring) #and do my stuff connection.close() c.close() t.close() if you have

python-ssh

拟墨画扇 提交于 2019-11-29 08:30:58
ssh username@目标机器ip -p 22 -o ProxyCommand = 'ssh -p 22 username@跳板机ip -W %h:%p' 1.1、基于用户名密码连接远程服务器 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import paramiko # 创建SSH对象 ssh = paramiko.SSHClient() # 允许连接不在know_hosts文件中的主机 ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # 连接服务器 ssh.connect(hostname = 'c1.salt.com' , port = 22 , username = 'shuaigaogao' , password = '0808' ) # 执行命令 stdin, stdout, stderr = ssh.exec_command( 'df' ) #stdin => 标准输入,就是你输入的那个命令 stdout => 标准输出,你输入命令后执行的结果 stderr => 标准错误,名利执行的过程中,如果出错了,就把这个错误打到这里 # 获取命令结果 result = stdout.read() #输出的结果是bytes类型的 # 关闭连接 ssh.close() 1.1.1