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
21
votes
7 answers

Paramiko Fails to download large files >1GB

def download(): if os.path.exists( dst_dir_path ) == False: logger.error( "Cannot access destination folder %s. Please check path and permissions. " % ( dst_dir_path )) return 1 elif os.path.isdir( dst_dir_path ) == False: logger.error(…
theegooch
  • 211
  • 1
  • 2
  • 5
20
votes
3 answers

Does paramiko close ssh connection on a non-paramiko exception

I'm debugging some code, which is going to result in me constantly logging in / out of some external sftp servers. Does anyone know if paramiko automatically closes a ssh / sftp session on the external server if a non-paramiko exception is raised in…
Ben
  • 51,770
  • 36
  • 127
  • 149
20
votes
2 answers

Wait until task is completed on Remote Machine through Python

I am writing a program in python on Ubuntu. In that program I am trying to print a message after completing a task "Delete a File" on Remote machine (RaspberryPi), connected to network. But In actual practice, print command is not waiting till…
Irfan Ghaffar7
  • 1,143
  • 4
  • 11
  • 30
20
votes
3 answers

Paramiko -- using encrypted private key file on OS X

I'm trying to use Paramiko to connect to an SSH server from Python. This is what I tried so far: >>> import paramiko >>> import os >>> privatekeyfile = os.path.expanduser('~/.ssh/id_rsa') >>> mykey =…
houbysoft
  • 32,532
  • 24
  • 103
  • 156
20
votes
1 answer

Elegant way to test SSH availability

I need a Python program I'm using to poll a remote server for SSH connectivity and notify when it is available. I am currently doing this using paramiko; attempt to connect, if failure, wait and retry until success or max retries. This works, but…
nightowl
  • 375
  • 1
  • 4
  • 10
19
votes
2 answers

How to see (log) file transfer progress using paramiko?

I'm using Paramiko's SFTPClient to transfer file between hosts. I want my script to print the file transfer progress similar to the output seen using scp. $ scp my_file user@host user@host password: my_file 100% 816KB…
user1071501
  • 211
  • 1
  • 2
  • 6
19
votes
8 answers

How to run sudo with Paramiko? (Python)

What I've tried: invoke_shell() then channel.send su and then sending the password resulted in not being root invoke_shell() and then channel.exec_command resulted in a "Channel Closed" error _transport.open_session() then channel.exec_command…
Takkun
  • 8,119
  • 13
  • 38
  • 41
19
votes
3 answers

Unable to connect to remote host using paramiko?

I want to transfer files between two Ubuntu Servers using scp, i have tested scp between the two systems and it worked perfectly fine.So i dont want to execute the command everytime i need to get files so i want to write a python script which…
SaiKiran
  • 6,244
  • 11
  • 43
  • 76
19
votes
1 answer

Paramiko SSH exec_command (shell script) returns before completion

I launch a shell script from a remote Linux machine using Paramiko. The shell script is launched and execute a command make -j8. However the exec_command returns before the completion of the make. If I launch the script on the local machine it…
Larry
  • 191
  • 1
  • 1
  • 3
19
votes
4 answers

How to check a remote path is a file or a directory?

I am using SFTPClient to download files from the remote server. However, I don't know if the remote path is a file or a directory. If the remote path is a directory, I need to handle this directory recursively. This is my code: def…
BlackMamba
  • 10,054
  • 7
  • 44
  • 67
18
votes
3 answers

Check whether a path exists on a remote host using paramiko

Paramiko's SFTPClient apparently does not have an exists method. This is my current implementation: def rexists(sftp, path): """os.path.exists for paramiko's SCP object """ try: sftp.stat(path) except IOError, e: if…
Sridhar Ratnakumar
  • 81,433
  • 63
  • 146
  • 187
18
votes
3 answers

"'Connection' object has no attribute '_sftp_live'" when pysftp connection fails

I'd like to catch nicely the error when "No hostkey for host *** is found" and give an appropriate message to the end user. I tried this: import pysftp, paramiko try: with pysftp.Connection('1.2.3.4', username='root', password='') as sftp: …
Basj
  • 41,386
  • 99
  • 383
  • 673
18
votes
6 answers

Paramiko: "not a valid RSA private key file"

I am trying connect to server using following spinet ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ip = ['x.x.x.x'] key_file = "/Users/user/.ssh/id_rsa" key =…
Owais Ahmad
  • 329
  • 1
  • 4
  • 8
18
votes
5 answers

ImportError: No module named 'cryptography'

I installed python 3.4 on windows 7 and when trying to use paramiko I get this error : import paramiko File "C:\Python34\lib\site-packages\paramiko-2.0.2-py3.4.egg\paramiko\__init__.py", line 30, in module File…
W4hf
  • 715
  • 1
  • 5
  • 12
18
votes
6 answers

paramiko python module hangs at stdout.read()

I am using the below code: import paramiko def runSshCmd(hostname, username, password, cmd, timeout=None): client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect(hostname,…
user3378508
  • 209
  • 1
  • 2
  • 8