编程语言
首页 > 编程语言> > 通过WEB页面来SSH 登录交换机 - Python webssh

通过WEB页面来SSH 登录交换机 - Python webssh

作者:互联网

本实验使用了基于tornado框架的webssh作为SSH时的中间代理。

 

Todo:
可以在网络CMDB中集成web ssh功能,通过只读权限的账号,方便查看设备信息。

 

1.服务架构 如下图所示
通过WEB页面来SSH 登录交换机 - Python webssh

 

2.实验拓扑
通过WEB页面来SSH 登录交换机 - Python webssh

 

3.配置过程
a.在webssh部署的服务器上进行配置

1.创建python 虚拟环境
python -m venv webssh

2.进入虚拟环境(win10)
cd webssh\Script
activate

3.安装webssh包
pip install webssh

4.开启webssh的服务(后续可以用supervisor之类的程序进行部署)
wssh --address="192.168.60.2" --port=80 --debug

 

b.在H3C交换机上配置SSH服务(可以参考官方文档

>display current-configuration 
#
 version 7.1.059, ESS 0322
#
 sysname H3C_TEST-NETCONF
#
 password-recovery enable
#
vlan 1
#
irf-port
#
interface GigabitEthernet2/0
 port link-mode route
 ip address 172.16.1.100 255.255.255.0
#
 port link-mode route
#
 scheduler logfile size 16
#
line vty 0 4
 authentication-mode scheme
 user-role network-operator
 protocol inbound ssh
#
line vty 15 63
 user-role network-operator
#
 ip route-static 0.0.0.0 0 172.16.1.3
#
 ssh server enable
#
domain system
#
 domain default enable system
#
user-group system
#
local-user admin class manage
 password hash $h$6$nle6SgoxU7MitBfn$YBoGKbWIjav412/UB1Uwdqf2bwJqkTS81ZP9r5HnsWuw+EXy1g9u9SzWlMURT2tqPNi421iwA21iPU7p4UNwZQ==
 service-type ssh
 authorization-attribute user-role network-admin
 authorization-attribute user-role network-operator
#
return

 

4.在client 192.168.60.72上访问webssh 服务,进而来SSH登录交换机
通过WEB页面来SSH 登录交换机 - Python webssh
通过WEB页面来SSH 登录交换机 - Python webssh

 

另外附上之前 远程Cisco IOS成功截图(不在该实验演示的范畴):
通过WEB页面来SSH 登录交换机 - Python webssh
通过WEB页面来SSH 登录交换机 - Python webssh

 

5.结论
实验成功

 
也可以直接通过url的拼接,发送GET请求:

http://<webssh-server-ip>/?hostname=xx&username=yy&password=str_base64_encoded

例如:
http://192.168.60.2/?hostname=172.16.1.101&username=admin&password=YWRtaW4=

 
base64在线编码地址:https://base64.us/
参考 webssh

标签:WEB,network,Python,webssh,user,password,port,ssh
来源: https://blog.51cto.com/jackor/2758678