Skip to main content

Fast and simple SSH library for interactive session based on Paramiko

Project description

Devnet-SSH

Version License: MIT

Fast and simple SSH library for interactive sessions based on Paramiko.

Supported Platforms

Currently tested on:

  • Cisco switches (IOS,IOS-XE,Nexus)
  • Cisco routers (IOS,IOS-XR,IOS-XE)
  • HP (Model 5920AF)
  • Huawei (Model NE40)
  • Linux Servers

Install

pip install devnet-ssh

Getting started

Establishing connection

from devnet_ssh import ssh_connect

session = SSHConnect(host="192.168.213.230",user="cisco",pwd="cisco") 

Executing commands

console = session.send_command("show ip int brief")
for line in console:
    print(line)
Interface                  IP-Address      OK? Method Status                Protocol
Embedded-Service-Engine0/0 unassigned      YES NVRAM  administratively down down
GigabitEthernet0/0         192.168.213.230 YES NVRAM  up                    up
GigabitEthernet0/1         unassigned      YES NVRAM  administratively down down
GigabitEthernet0/1.1       unassigned      YES unset  administratively down down
GigabitEthernet0/1.75      10.71.89.1      YES NVRAM  administratively down down
GigabitEthernet0/1.626     10.33.62.121    YES NVRAM  administratively down down
GigabitEthernet0/1.777     192.168.1.1     YES NVRAM  administratively down down
GigabitEthernet0/1.918     10.30.83.161    YES manual administratively down down
GigabitEthernet0/1.990     10.13.87.1      YES NVRAM  administratively down down

Connecting to a different vendor

You can choose between supported vendors:

  • SSHConnect.CISCO
  • SSHConnect.HP
  • SSHConnect.HUAWEI

os_type is associated with device prompt (# for Cisco, > for HP/Huawei) and it sends the appropiate commands for disable scrolling after establishing connection.

from devnet_ssh import SSHConnect

session = SSHConnect(host="192.168.213.231",user="huawei",pwd="huawei",os_type=SSHConnect.HUAWEI)
console = session.send_command("display ip routing-table")
for line in console:
    print(line)
Route Flags: R - relay, D - download to fib, T - to vpn-instance, B - black hole route
------------------------------------------------------------------------------
Routing Table : _public_
Destinations : 8        Routes : 8
Destination/Mask    Proto   Pre  Cost        Flags NextHop         Interface
0.0.0.0/0   Static  1    0             RD  192.168.213.225 GigabitEthernet0/3/23
127.0.0.0/8   Direct  0    0             D   127.0.0.1       InLoopBack0
127.0.0.1/32  Direct  0    0             D   127.0.0.1       InLoopBack0
127.255.255.255/32  Direct  0    0             D   127.0.0.1       InLoopBack0
192.168.213.224/27  Direct  0    0             D   192.168.213.231 GigabitEthernet0/3/23
192.168.213.231/32  Direct  0    0             D   127.0.0.1       GigabitEthernet0/3/23
192.168.213.255/32  Direct  0    0             D   127.0.0.1       GigabitEthernet0/3/23
255.255.255.255/32  Direct  0    0             D   127.0.0.1       InLoopBack0

Author

👤 Gustavo Santiago

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

devnet_ssh-1.0.5.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

devnet_ssh-1.0.5-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file devnet_ssh-1.0.5.tar.gz.

File metadata

  • Download URL: devnet_ssh-1.0.5.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for devnet_ssh-1.0.5.tar.gz
Algorithm Hash digest
SHA256 d9249472461bc9d22fbfd46b7ae77e7ce3eb91280e6f41bf839989fabffd1377
MD5 ccca374bbef6747e8105d747cf779f66
BLAKE2b-256 4510e1ba4e6c9ae4560344a9b14c2daacf81ffc7cef3ea9da290bc8dfa493588

See more details on using hashes here.

File details

Details for the file devnet_ssh-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: devnet_ssh-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for devnet_ssh-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 495572df700a3ab97de2b1f2e2e1bda42732a0d2fb5ff79397dd0a0d41cfcb81
MD5 1b6f1278ab064ab6c6b7dde92460787d
BLAKE2b-256 8d4d476e12bdb9ca2a381fcb2f6cec612849f593f428b7d3ed9119b35ad30654

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page