Fast and simple SSH library for interactive session based on Paramiko
Project description
Devnet-SSH
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
- Github: @jcdaniel14
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 hashes)
Built Distribution
Close
Hashes for devnet_ssh-1.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 495572df700a3ab97de2b1f2e2e1bda42732a0d2fb5ff79397dd0a0d41cfcb81 |
|
MD5 | 1b6f1278ab064ab6c6b7dde92460787d |
|
BLAKE2b-256 | 8d4d476e12bdb9ca2a381fcb2f6cec612849f593f428b7d3ed9119b35ad30654 |