Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Python wrapper for libssh (http://www.libssh.org).
Python
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib/libssh
.gitignore
COPYING
README.md
setup.py

README.md

python-libssh

python-libssh is a Python wrapper for the libssh C library. It is implemented using the ctypes module from stdlib.

Warning: This code is in early alpha and may produce unexpected results. Please use with caution.

Example Usage

import stat
import os

from libssh import *

# open an SSH session to 'smart.host.com'
ssh = SshSession('smart.host.com', 'ubuntu', password='password')

# or, for public key authentication
# ssh = SshSession('smart.host.com', 'ubuntu')

channel = ssh.get_channel()
channel.execute_command("whoami")
channel.read()
channel.close()

channel = ssh.get_channel()
channel.execute_sudo_command("whoami")
channel.read()
channel.close()

sftp = SftpSession(ssh)
f = sftp.open("foo.txt", (os.O_WRONLY | os.O_CREAT | os.O_TRUNC), stat.S_IRWXU)
f.write("hello world")
f.close()
sftp.close()

Author

Matthew Williams -- mgwilliams@gmail.com

Something went wrong with that request. Please try again.