Wrapper ssh using paramiko to interact with remote servers
Project description
ssh_paramiko
ssh_paramiko is a wrapper utility around ssh, using paramiko, to execute commands and exchange files remotelly
Usage
Executing a simple remote command
>>> from ssh_paramiko import RemoteServer
>>> ssh = RemoteServer('/tmp/sshkey',logFolder='.')
>>> ssh.set_log_level('DEBUG')
Log: Changing log level to DEBUG | Log level:DEBUG | Date:01/11/2016 12:04:40
>>> ssh.set_log_rotate_handler(True) # set bzipped log files (ssh_paramiko.debug.log.bz2
# and ssh_paramiko.error.log.bz2) to be rotated
>>> ssh.connect_server('myServer')
Log: Connecting to server myServer | Log level:DEBUG | Date:01/11/2016 12:04:41
Log: Initiating connection with server myServer... | Log level:DEBUG | Date:01/11/2016 12:04:41
Log: Instantiating transport object for sftp... | Log level:DEBUG | Date:01/11/2016 12:04:41
(True, '')
>>> ssh.execute_cmd('whoami')
(True, 'root\n', '')
>>> ssh.close_connection()
Log: Connection with server myServer ended. | Log level:INFO | Date:01/11/2016 12:04:45
True
Transfering a remote file to a local file
>>> from ssh_paramiko import RemoteServer
>>> ssh = RemoteServer('/tmp/sshkey',logFolder='.')
>>> ssh.set_log_level('DEBUG')
Log: Changing log level to DEBUG | Log level:DEBUG | Date:01/11/2016 12:04:40
>>> ssh.set_log_rotate_handler(True) # set bzipped log files (ssh_paramiko.debug.log.bz2 and
# ssh_paramiko.error.log.bz2) to be rotated
>>> ssh.connect_server('myServer')
Log: Connecting to server myServer | Log level:DEBUG | Date:01/11/2016 12:04:41
Log: Initiating connection with server myServer... | Log level:DEBUG | Date:01/11/2016 12:04:41
Log: Instantiating transport object for sftp... | Log level:DEBUG | Date:01/11/2016 12:04:41
(True, '')
>>> ssh.get_file('local_file.py', '/root/remote_file.py', callBack=ssh.transferProgressBar)
Log: Transfering remote file /root/remote_file.py from server myServer to local file local_file.py
| Log level:DEBUG | Date:01/11/2016 12:08:15
TrueSize: 542 bytes(0.0 MB) || File transfered. [###################################] 100.0%
>>> ssh.close_connection()
Log: Connection with server myServer ended. | Log level:INFO | Date:01/11/2016 12:04:45
True
Transfering a local file to a remote file
>>> from ssh_paramiko import RemoteServer
>>> ssh = RemoteServer('/tmp/sshkey',logFolder='.')
>>> ssh.set_log_level('DEBUG')
Log: Changing log level to DEBUG | Log level:DEBUG | Date:01/11/2016 12:07:40
>>> ssh.set_log_rotate_handler(True) # set bzipped log files (ssh_paramiko.debug.log.bz2 and
# ssh_paramiko.error.log.bz2) to be rotated
>>> ssh.connect_server('myServer')
Log: Connecting to server myServer | Log level:DEBUG | Date:01/11/2016 12:07:41
Log: Initiating connection with server myServer... | Log level:DEBUG | Date:01/11/2016 12:07:41
Log: Instantiating transport object for sftp... | Log level:DEBUG | Date:01/11/2016 12:07:41
(True, '')
>>> ssh.put_file('local_file.py', '/root/remote_file.py', callBack=ssh.transferProgressBar)
Log: Transfering local file local_file.py to remote file /root/remote_file.py in server myServer |
Log level:DEBUG | Date:01/11/2016 12:07:44
TrueSize: 542 bytes(0.0 MB) || File transfered. [###################################] 100.0%
>>> ssh.close_connection()
Log: Connection with server myServer ended. | Log level:INFO | Date:01/11/2016 12:07:44
True
Installation
To install ssh_paramiko, simply run:
$ pip install ssh_paramiko
ssh_paramiko is compatible with Python 2.6+
Documentation
Source Code
Feel free to fork, evaluate and contribute to this project.
License
GPLv3 licensed.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ssh_paramiko-0.1.2.tar.gz
(27.3 kB
view details)
Built Distribution
ssh_paramiko-0.1.2-py2.7.egg
(6.4 kB
view details)
File details
Details for the file ssh_paramiko-0.1.2.tar.gz
.
File metadata
- Download URL: ssh_paramiko-0.1.2.tar.gz
- Upload date:
- Size: 27.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ecb244bd232535623a48e0b1f0b40f8803c326b6e3577a2f8424d478273ccaea |
|
MD5 | 0e7753535e7674d0807bfa89d1c6fc67 |
|
BLAKE2b-256 | 25c5c21c2b8ca72b9918f9be06e41abe106c8f5d702546335fcd47a1ac2087fe |
File details
Details for the file ssh_paramiko-0.1.2-py2.7.egg
.
File metadata
- Download URL: ssh_paramiko-0.1.2-py2.7.egg
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2f7b31463956dd4f4091c2a8ca461f00bb78408bbcdf3f0559900579d13ef80 |
|
MD5 | 5eccd8e210e461ed0ee8b323139354ba |
|
BLAKE2b-256 | a98bfc4f44ba357128f573ef4aeb5bf64d29531259bbc3b3c82179fc4e2395c6 |