Questions tagged [paramiko]

Paramiko is a Python module that implements the SSH2 protocol.

Paramiko is a Python module that implements the SSH2 protocol. It is written entirely in Python and released under the GNU LGPL license.

Links:

2658 questions
25
votes
6 answers

Long-running ssh commands in python paramiko module (and how to end them)

I want to run a tail -f logfile command on a remote machine using python's paramiko module. I've been attempting it so far in the following fashion: interface = paramiko.SSHClient() #snip the connection setup portion stdin, stdout, stderr =…
user17925
  • 989
  • 2
  • 10
  • 20
25
votes
4 answers

Check if paramiko ssh connection is still alive

Is there a way to check if a paramiko SSH connection is still alive? In [1]: import paramiko In [2]: ssh = paramiko.SSHClient() In [3]: ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) In [4]: ssh.connect(hostname) I want to mimic…
MRocklin
  • 55,641
  • 23
  • 163
  • 235
25
votes
2 answers

Port forwarding with Paramiko

I'm trying to do some port forwarding from a python app using Paramiko. I can set up the SSH connection just fine, but I'm a bit stumped as to how to use paramiko.Transport. I've already found this file, but I can't work out what's going on in it.…
TimD
  • 1,371
  • 3
  • 12
  • 20
24
votes
4 answers

Paramiko and Pseudo-tty Allocation

I'm trying to use Paramiko to connect to a remote host and execute a number of text file substitutions. i, o, e = client.exec_command("perl -p -i -e 's/" + initial + "/" + replaced + "/g'" + conf); Some of these…
Jonathan Holloway
  • 62,090
  • 32
  • 125
  • 150
24
votes
2 answers

How to use Paramiko logging?

I'm using Paramiko in Python to run command on a box through SSH. How to use Paramiko logging? I mean force it to make logs (in a file or terminal) and set the log level.
Jason007
  • 288
  • 1
  • 2
  • 6
23
votes
4 answers

Nested SSH using Python Paramiko

I have this scenario: Local-host --------- jump-host ------- target-machine I am trying to write a code in Python using Paramiko to first SSH from local-host to jump-host and then SSH from jump-host to the target-machine. From the target-machine, I…
Usman
  • 233
  • 1
  • 2
  • 4
23
votes
2 answers

How to transfer a file to ssh server in an ssh-connection made by paramiko?

I am using Python's paramiko packet to keep an ssh-connection with an server : s = paramiko.SSHClient() s.set_missing_host_key_policy(paramiko.AutoAddPolicy()) s.connect("xxx.xxx.xxx.xxx",22,username=xxx,password='',timeout=4) I want to use this…
Coaku
  • 977
  • 1
  • 9
  • 23
23
votes
6 answers

python paramiko ssh

i'm new on python. i wrote a script to connect to a host and execute one command ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(host, username=user, password=pw) print 'running remote…
user1008764
  • 390
  • 1
  • 3
  • 7
22
votes
5 answers

How do use paramiko.RSAKey.from_private_key()?

Any idea how I can use the paramiko.RSAKey.from_private_key() function? I know there is a from_private_key_file(), but I'm interested in using a function to parse a private key (like below) and use that private key for SSHClient. Private key…
Mickey Cheong
  • 2,980
  • 6
  • 38
  • 50
22
votes
2 answers

After executing a command by Python Paramiko how could I save result?

As you see below, is it possible to save the result? Cause, at second and third stdout.read() I couldn't reach the result. import paramiko import os dssh =…
MrCskncn
  • 328
  • 1
  • 3
  • 16
22
votes
2 answers

Paramiko SSH failing with "Server '...' not found in known_hosts" when run on web server

I am trying to use Paramiko to make an SSH communication between 2 servers on a private network. The client server is a web server and the host server is going to be a "worker" server. The idea was to not open up the worker server to HTTP…
jeffery_the_wind
  • 17,048
  • 34
  • 98
  • 160
22
votes
3 answers

Implement an interactive shell over ssh in Python using Paramiko?

I want to write a program (in Python 3.x on Windows 7) that executes multiple commands on a remote shell via ssh. After looking at paramikos' exec_command() function, I realized it's not suitable for my use case (because the channel gets closed…
misha
  • 777
  • 1
  • 9
  • 21
22
votes
3 answers

Creating multiple SSH connections at a time using Paramiko

The code below runs grep in one machine through SSH and prints the results: import sys, os, string import paramiko cmd = "grep -h 'king' /opt/data/horror_20100810*" ssh =…
Whit3H0rse
  • 569
  • 2
  • 8
  • 16
21
votes
6 answers

Paramiko authentication fails with "Agreed upon 'rsa-sha2-512' pubkey algorithm" (and "unsupported public key algorithm: rsa-sha2-512" in sshd log)

I have a Python 3 application running on CentOS Linux 7.7 executing SSH commands against remote hosts. It works properly but today I encountered an odd error executing a command against a "new" remote server (server based on RHEL 6.10): encountered…
donmelchior
  • 893
  • 3
  • 13
  • 31
21
votes
4 answers

Import Error from cyptography.hazmat.bindings._constant_time import lib

So I'm trying to create an aws lambda function, to log in to an instance and do some stuff. And the script works fine outside of lambda, but when I package it using the same instructions as this…
Luis F Hernandez
  • 891
  • 2
  • 14
  • 29