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
218
votes
13 answers

How to scp in Python?

What's the most pythonic way to scp a file in Python? The only route I'm aware of is os.system('scp "%s" "%s:%s"' % (localfile, remotehost, remotefile) ) which is a hack, and which doesn't work outside Linux-like systems, and which needs help…
Michael Gundlach
  • 106,555
  • 11
  • 37
  • 41
117
votes
4 answers

How can you get the SSH return code using Paramiko?

client = paramiko.SSHClient() stdin, stdout, stderr = client.exec_command(command) Is there any way to get the command return code? It's hard to parse all stdout/stderr and know whether the command finished successfully or not.
Beyonder
  • 1,425
  • 3
  • 11
  • 8
103
votes
5 answers

Paramiko's SSHClient with SFTP

How I can make SFTP transport through SSHClient on the remote server? I have a local host and two remote hosts. Remote hosts are backup server and web server. I need to find on backup server necessary backup file and put it on web server over SFTP.…
Denis
  • 7,127
  • 8
  • 37
  • 58
89
votes
8 answers

Paramiko : Error reading SSH protocol banner

Recently, I made a code that connect to work station with different usernames (thanks to a private key) based on paramiko. I never had any issues with it, but today, I have that : SSHException: Error reading SSH protocol banner This is strange…
FunkySayu
  • 7,641
  • 10
  • 38
  • 61
76
votes
4 answers

How to ssh connect through Python Paramiko with ppk public key

I'm using Paramiko to connect through SSH to a server. Basic authentication works well, but I can't understand how to connect with public key. When I connect with PuTTY, the server tell me this: Using username "root". Authenticating with public key…
apelliciari
  • 8,241
  • 9
  • 57
  • 92
64
votes
4 answers

How to suppress a third-party warning using warnings.filterwarnings

I am using Paramiko in my python code (for sftp). Everything works fine except that everytime I import or call a paramiko function. This warning would show up: C:\Python26\lib\site-packages\Crypto\Util\randpool.py:40: RandomPool_Deprecation Warning:…
Tom Nguyen
  • 641
  • 1
  • 5
  • 3
55
votes
8 answers

How do you execute multiple commands in a single session in Paramiko? (Python)

def exec_command(self, command, bufsize=-1): #print "Executing Command: "+command chan = self._transport.open_session() chan.exec_command(command) stdin = chan.makefile('wb', bufsize) stdout = chan.makefile('rb', bufsize) …
Takkun
  • 8,119
  • 13
  • 38
  • 41
49
votes
6 answers

Read a file from server with SSH using Python

I am trying to read a file from a server using SSH from Python. I am using Paramiko to connect. I can connect to the server and run a command like cat filename and get the data back from the server but some files I am trying to read are around 1 GB…
randomThought
  • 6,203
  • 15
  • 56
  • 72
49
votes
3 answers

How to list all the folders and files in the directory after connecting through SFTP in Python

I am using Python and trying to connect to SFTP and want to retrieve an XML file from there and need to place it in my local system. Below is the code: import paramiko sftpURL = 'sftp.somewebsite.com' sftpUser = 'user_name' sftpPass = …
Shiva Krishna Bavandla
  • 25,548
  • 75
  • 193
  • 313
48
votes
7 answers

Running interactive commands in Paramiko

I'm trying to run an interactive command through paramiko. The cmd execution tries to prompt for a password but I do not know how to supply the password through paramiko's exec_command and the execution hangs. Is there a way to send values to the…
Sharmila
  • 1,637
  • 2
  • 23
  • 30
47
votes
4 answers

How do I change directories using Paramiko?

Drush commands not executing using Paramiko I posted the above question regarding a persistent error message that I receive using Paramiko. I do not think it is related to my next question, but it might be. I can successfully connect to my server…
Mike Ryan
  • 2,359
  • 2
  • 17
  • 24
43
votes
3 answers

How to avoid [Errno 12] Cannot allocate memory errors caused by using subprocess module

Complete Working Test Case Of course depending on your memory on the local and remote machines your array sizes will be different. z1 = numpy.random.rand(300000000,2); for i in range(1000): print('*******************************************\n');…
Paul
  • 7,155
  • 8
  • 41
  • 40
41
votes
8 answers

Homebrew Error: No formulae found in taps

I'm trying to install paramiko on my MacBook Pro (OSX Sierra) without going through Xcode because I'm too lazy to install Xcode honestly. When trying to run: brew install paramiko I get: Error: No available formula with the name "paramiko" ==>…
CBK
  • 660
  • 1
  • 7
  • 16
40
votes
6 answers

Paramiko "Unknown Server"

I'm trying to get started with the Paramiko library, but the library is throwing an exception as soon as I try to connect with the following simple program: import paramiko ssh = paramiko.SSHClient() ssh.connect('127.0.0.1', username='boatzart',…
rcv
  • 6,078
  • 9
  • 43
  • 63
39
votes
14 answers

Directory transfers with Paramiko

How do you use Paramiko to transfer complete directories? I'm trying to use: sftp.put("/Folder1","/Folder2") which is giving me this error - Error : [Errno 21] Is a directory
fixxxer
  • 15,568
  • 15
  • 58
  • 76
1
2 3
99 100