Skip to main content

Devmiko


PyPI - Status PyPI - Format GitHub GitHub release (latest by date) PyPI - Python Version

A SSH client for systems network automation.

Documentation

Paramiko - SFTPClient
Paramiko - SSHClient

Dependencies

Paramiko

How to install

$ pip install Devmiko

Usage

The client.output holds the full output from all the commands you sent.

SSHClient example

import Devmiko

client = Devmiko.SSHClient(debug=False, filename=None, level='DEBUG')
client.connect('remote_host', username='myusername', password='mypassword')

client.send_command('ls')
client.send_command('sudo su', expect_string=r'^.*Password: $')
client.send_command('mypassword')
print(client.output)

client.disconnect()

Turn on debugging to help you troubleshoot issues with the SSH connection

import Devmiko

client = Devmiko.SSHClient(debug=True, filename='mylogfile.log', level='DEBUG')

You can pass arguments and keyword arguments to the paramiko connection method. Check out the paramiko docs

import Devmiko

client = Devmiko.SSHClient()
client.connect(*args, **kwargs)

How to break out of a prompt? You have to pass the keyword argument expect_string with a regex

import Devmiko

client = Devmiko.SSHClient()
client.connect('remote_host', username='myusername', password='mypassword')

client.send_command('sudo su', expect_string=r'^.*Password: $') # Here we are breaking the prompt at Password:
client.send_command('mypassword')

client.disconnect()

Using Paramiko methods from the Devmiko channel

import Devmiko
import re

client = Devmiko.SSHClient()
client.connect('remote_host', username='myusername', password='mypassword')

client.channel.sendall('ls\n')
output = ''
while True:
    temp_output = client.channel.recv(4096).encode('UTF-8')
    output += temp_output
    if re.search(r'>\s$', temp_output, flags=re.IGNORECASE | re.MULTILINE):
        break

print(output)

client.disconnect()

SFTPClient example

For the SFTPClient you need to use the client.channel and use the paramiko methods

import Devmiko

client = Devmiko.SFTPClient()
client.connect('remote_host', username='myusername', password='mypassword')

client.channel.chdir(path='/tmp')
output = client.channel.getcwd()
print(output)
output = client.channel.listdir(path='.')
print(output)
client.channel.get('/tmp/Cleanup.log', 'Downloads/Cleanup.log')

client.disconnect()

Download Files with Progressbar

import Devmiko

client = Devmiko.SFTPClient()
client.connect('remote_host', username='myusername', password='mypassword')

client.get_with_progressbar(remote_file='/tmp/myfile.tar', local_file='Downloads/myfile.tar')

client.disconnect()

Upload Files with Progressbar

import Devmiko

client = Devmiko.SFTPClient()
client.connect('remote_host', username='myusername', password='mypassword')

client.put_with_progressbar(local_file='myfile.tar', remote_file='/tmp/myfile.tar')

client.disconnect()

FTDClient example

The FTDClient include the different Command Line Modes of the FTD so you can enter or switch from mode to mode.

import Devmiko

client = Devmiko.FTDClient(debug=False, filename=None, level='DEBUG')
client.connect('remote_host', username='myusername', password='mypassword')

client.send_command(command='show managers')

client.enter_lina_mode()
client.send_command(command='show run | include hostname')

client.enter_clish_mode()
client.send_command(command='show managers')
client.send_command(command='show failover')

client.enter_diagnostic_cli_mode()
client.send_command(command='show run | include hostname')

client.enter_expert_mode()
client.send_command(command='ls /tmp')

client.enter_regular_mode()
client.send_command(command='show managers')
client.send_command(command='show network')


print(client.output)
client.disconnect()

Metadata

Release files for Devmiko 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Devmiko 0.0.3
File Size Uploaded Provenance Actions
Devmiko-0.0.3.tar.gz 5.7 kB Without provenance Details for Devmiko-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for Devmiko 0.0.3
File Interpreter ABI Platform Actions
Devmiko-0.0.3-py3-none-any.whl Python 3 none any Details for Devmiko-0.0.3-py3-none-any.whl

Total release size: 11.5 kB

Release files / Devmiko-0.0.3.tar.gz

Download URL Devmiko-0.0.3.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
35d457f97eda6eec08423bfb63b70f35528a74ecaeaac06bf2af16fd044c093b
BLAKE2b-256 checksum
How to use checksums
b22e5a8062db5fe4f0d4dcc7ac2aea0add44feb7685d96cbe6b55f36f173453c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

Release files / Devmiko-0.0.3-py3-none-any.whl

Download URL Devmiko-0.0.3-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
42f3c88b9ff8d533179282da3581d6637847ba58d0396bfd1c64f5ecb1422dc7
BLAKE2b-256 checksum
How to use checksums
e31e779a632f148701e0c197a60b507c0a62ac457c21e642e786dbc43c8ccc04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

Security for Devmiko 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page