zoukankan      html  css  js  c++  java
  • Python远程控制工具--paramiko

    基础代码:

    # -*- coding:utf-8 -*-
    # import 导入模块 import paramiko import time # 定义三个字符串类型的变量 ip
    = '192.168.113.133' username = 'zhoujt' password = 'password' port = 33306 # 开启SSH会话赋值给变量 ssh_client = paramiko.SSHClient() # 开启可接收陌生的ssh服务会话 ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh_client.connect(hostname=ip, username=username, password=password, look_for_keys=False) # 开启交互式会话 command = ssh_client.invoke_shell() print ('已经成功登陆路由器' + ip) # 向路由器发出命令 command.send('configure terminal ') command.send('interface loop 0 ') command.send('ip add 1.1.1.1 255.255.255.255 ') command.send('end ') command.send('wr mem ') # 延时5秒 time.sleep(5) # 设置截屏长度并打印出来 output = command.recv(65535).decode('ascii') print (output) # 退出ssh会话 ssh_client.close

    路由命令

    display current-configuration 显示当前配置
    display interface GigabitEthernet 1/1/4  显示接口信息
    display packet-filter interface GigabitEthernet 1/1/4 显示接口acl应用信息
    display acl all 显示所有acl设置 3900系列zhi交换机
    display acl config all 显示所有acl设置 6500系列交换机
    display arp 10.78.4.1  显示该ip地址的mac地址,所接交换机的端口位置
    display cpu显示cpu信息
    system-view 进入系统图(配置交换机),等于config t 命令
    acl number 5000 在system-view命令后使用,进入acl配置状态
    rule 0 deny 0806 ffff 24 0a4e0401 f 40 在上面的命令后使用,acl 配置例子
    rule 1 permit 0806 ffff 24 000fe218ded7 f 34   //在上面的命令后使用,acl配置例子
    interface GigabitEthernet 1/0/9   //在system-view命令后使用,进入接口配置状态
    [86ZX-S6503-GigabitEthernet1/0/9]qos   //在上面的命令后使用,进入接口qos配置
    [86ZX-S6503-qosb-GigabitEthernet1/0/9]packet-filter inbound user-group 5000 //在上面的命令后使用,在接口上应用进站的acl
    [Build4-2_S3928TP-GigabitEthernet1/1/4]packet-filter outbound user-group 5001 //在接口上应用出站的acl
    undo acl number 5000 //取消acl number 5000 的设置
    ip route-static 0.0.0.0 0.0.0.0 10.78.1.1 preference 60   //设置路由
    reset counters interface Ethernet 1/0/14   //重置接口信息
    save //保存设置
    quit //退出
    

      

  • 相关阅读:
    微擎 关注发送推荐消息
    修改 processor.php 文件,监听用户对该应用的消息
    微擎返回图文信息
    微擎客服消息发送的函数
    mui 底部导航栏的实现
    两张表的关联查询
    微擎 截取字符串
    webStorm中NodeJs 没有智能提示
    OpenCV 实现自己的线性滤波器
    OpenCV 基本的阈值操作
  • 原文地址:https://www.cnblogs.com/security-guard/p/14635829.html
Copyright © 2011-2022 走看看