rdegges
rdegges

Reputation: 33824

Python SSH / SFTP Module?

I've been looking around for a module which allows me to do SSH / SFTP functions in python without using POPEN to do it manually. Is there anything like this? I haven't found any real information on this, thanks!

Upvotes: 11

Views: 21254

Answers (4)

Ringding
Ringding

Reputation: 2856

paramiko works nicely: Paramiko Homepage

Upvotes: 4

Carl Hill
Carl Hill

Reputation: 314

You're probably looking for the excellent paramiko library:

http://www.paramiko.org/

Upvotes: 14

Franck Dernoncourt
Franck Dernoncourt

Reputation: 83177

For SFTP, you can use pysftp, which is a thin wrapper over paramiko's SFTPClient (pip install sftp).

Example to download a file:

import pysftp #pip install sftp
import sys

hostname = "128.65.45.12"
username = "bob"       
password = "123456"  

sftp = pysftp.Connection(hostname, username=username, password=password)

sftp.get('/data/word_vectors/GoogleNews-vectors-negative300.txt', preserve_mtime=True)
print('done')

Upvotes: 2

Cole Tuininga
Cole Tuininga

Reputation: 11

Depending on what you're looking to do over ssh, you might also benefit from looking at the pexpect library: http://www.noah.org/wiki/pexpect

Upvotes: 1

Related Questions