filmov
tv
GNS3 Talks: Python for Network Engineers with GNS3 (Part 11) - Paramiko, SSH, Python and Cisco
Показать описание
Learn Python programming with GNS3. In this series of videos I will show you how you can quickly and easily program Cisco networks using Python.
================================
Script on GitHub:
================================
================================
Install Paramiko:
================================
apt-get update
apt-get install python -y
apt-get install build-essential libssl-dev libffi-dev -y
apt-get install python-pip -y
apt-get installpython-dev # You may need to install this as well
pip install cryptography
pip install paramiko
================================
Al's GNS3 community entry:
================================
Transcription:
Since I started recording the Python for Network Engineers videos, the number one request has been to demonstrate the use of SSH with Python and Cisco devices.
So as we can see here, there are a number of requests for SSH and Paramiko.
This is one of multiple videos teaching you network programmability using Python and GNS3.
Al, as an example has even gone further and created an entry on the GNS3 community showing you how to install Paramiko and Netmiko on the Ubuntu client that I've been demonstrating in these videos. So thanks Al for sharing.
I'm going to demonstrate how to install Paramiko using the steps that Al has shared on the GNS3 community.
In this topology I've got an Ubuntu docker container which I've configured to use DHCP. That's now booted and got an IP address from the NAT cloud.
So I'll demonstrate in a moment how to configure SSH on the switch and then we'll configure the Ubuntu client to use Paramiko and SSH to configure the switch. The module that I'm going to use for SSH is Paramiko.
I've written a script which I've linked below on github that imports Paramiko and uses SSH to connect to the Cisco switch and configure some options on the switch. We'll configure some loopback interfaces and then we'll run a loop to configure VLANs on the switch.
So I'm hoping that this video and script help you configure network devices using SSH rather than just relying on telnet.
Ok so the first thing we need to do is install Paramiko and Python on this Ubuntu client. This Ubuntu client has just booted up, doesn't have any configuration apart from an IP address.
So what I'll simply do here is follow the list of commands that Al has put on the GNS3 community and I'll reference the links below.
So install Python, install some additional software, install pip. I'll use pip to install cryptography and then we'll use pip to install Paramiko. You simply need to wait for the processes to complete. So install Paramiko here as well and I'll upgrade pip while I'm here.
So once again, Paramiko is now installed on this Ubuntu server.
So that's been done. I'll specify an enable password of cisco and in this example I'll configure a username of david password of cisco and give david level 15 privileges on the vty lines.
I'll use the login local command and transport input all. So SSH is now configured on the switch. what we can do now is have a look at our python script. So we're going to import Paramiko, we're also going to import a time you may want to add some delays in your script and that's what sleep allows you to do. So I'm sleeping one second before I'm outputting the session when I'm creating the VLANs on the switch.
Комментарии