NETWORKJOURNEY PYTHON AUTOMATION
  • Start Here
        • Course Level 1 : Beginners
          • CCNA
          • CISCO DEVNET 200-901
          • LINUX
          • AWS ASSOCIATE
          • BASIC NETWORK FUNDAMENTALS
        • Course Level 2 : Intermediate
          • CCNP ENTERPRISE (ENCOR+ENARSI)
          • PYTHON, ANSIBLE AUTOMATION
          • FIREWALL MASTERY 5IN1
          • COMBO: OSPF + BGP +MPLS
          • COMBO: VPN MASTERY 10IN1
        • Course Level 3 : Advance
          • CCIE LAB ENTERPRISE
          • CISCO DEVNET ENAUTO
          • SDWAN 300-415
          • COMBO: ACI + NEXUS + SDWAN
          • CCIE SP
          • CCIE DC
        • Bootcamps : FastTrack
          • PYTHON AUTOMATION IN 3 WEEKS
          • CCNP IN 2 MONTHS
          • CCNA IN 21 DAYS
  • About Us
  • Schedule 2025
  • Blog
  • Courses
  • Practice Test
  • Contact Us

[DAY#5 PyATS Series] Connecting to Cisco/Arista/Paloalto/Fortigate devices (SSH) Using pyATS [Python for Network Engineers]

  • Home
  • Network Automation using Python3
  • [DAY#5 PyATS Series] Connecting to Cisco/Arista/Paloalto/Fortigate devices (SSH) Using pyATS [Python for Network Engineers]
[DAY#5 PyATS Series] Connecting to Cisco/Arista/Paloalto/Fortigate devices (SSH) Using pyATS [Python for Network Engineers]
  • Sagar Dhawan
  • Posted on July 19, 2025
  • No Comments

[DAY#5 PyATS Series] Connecting to Cisco/Arista/Paloalto/Fortigate devices (SSH) Using pyATS [Python for Network Engineers]

Post Views: 115

Table of Contents

  • Introduction: A Real-World Take on Network Automation
  • Topology Overview
  • Why Vendor‑Agnostic Testing Matters
  • Topology & Communications
  • Workflow Script (Basic SSH Connection to Multi-Vendor Devices)
  • Explanation by Line
  • testbed.yml
  • Multi-Vendor CLI
    • Cisco IOS
    • Arista EOS
    • FortiGate
    • Palo Alto
  • FAQs
    • 1. What if a device uses a different username/password?
    • 2. Can this work without a testbed file?
    • 3. Why does FortiGate or Palo Alto sometimes refuse SSH?
    • 4. Is this script scalable to 100+ devices?
    • 5. Can I parse command outputs like show ip route?
    • 6. How do I debug failed SSH sessions?
    • 7. Can I use Ansible instead of pyATS for this?
    • 8. What’s the benefit of Unicon over Paramiko/Netmiko?
  • YouTube Link
  • Join Our Training

Introduction: A Real-World Take on Network Automation

Have you ever been in a situation where you had to pull device inventory, verify version info, or just log into 15+ devices from different vendors like Cisco, Arista, FortiGate, or Palo Alto? It’s not fun doing that manually—especially when every vendor throws its own flavor into CLI syntax and connection behaviors

That’s where pyATS comes in. Whether you’re scripting daily tasks or building a multi-vendor testbed, learning Python for Network Engineer automation gives you superpowers. Today, we’ll connect to Cisco, Arista, Palo Alto, and FortiGate devices over SSH using a single pyATS framework.

This is part of our “101 Days of pyATS” journey—hands-on, vendor-agnostic, and crafted for serious learners like you.


Topology Overview

Here’s our simple but powerful multi-vendor lab setup:

  • Mgmt IPs: Pre-configured with SSH enabled
  • Username/Password: Common for all (or stored via Vault/Env vars in production)
  • Python Version: 3.8+
  • pyATS version: Genie >=23.x

Why Vendor‑Agnostic Testing Matters

Enterprise networks today are no longer “Cisco-only.” Whether you’re working with ISPs, fintech, or cloud service providers, multi-vendor environments are now the norm.

Here’s why vendor-agnostic automation using pyATS makes sense:

ChallengepyATS Advantage
CLI differences across OSpyATS abstracts via connection logic
Onboarding delayOne YAML, connect all devices
Manual script rewritesTemplates and reusable testbeds
Multiple SSH librariesUnified framework with Unicon
Error-prone login scriptsBuilt-in parser and error handling

Bottom line: Write once, connect to all.


Topology & Communications

All devices are reachable via management IPs. You’ll need to ensure:

  • SSH is enabled
  • Username/password access works
  • TCP/22 allowed through any firewalls
  • Testbed is reachable from your pyATS runner machine
DeviceVendormgmt IPOS/Platform
R1Cisco IOS10.0.0.11IOSv
SW1Arista EOS10.0.0.12vEOS
FW1FortiGate10.0.0.13FortiOS
PA1Palo Alto10.0.0.14PAN-OS

Make sure to test ssh admin@10.0.0.x manually before running your script.


Workflow Script (Basic SSH Connection to Multi-Vendor Devices)

Here’s your base script using pyATS and Unicon:


from genie.testbed import load

# Load testbed from YAML
testbed = load('testbed.yml')

for device in testbed.devices.values():
    print(f"Connecting to {device.name} ({device.os})")
    try:
        device.connect(log_stdout=False)
        print(f"Connected to {device.name}")
        print(device.execute("show version"))
        device.disconnect()
    except Exception as e:
        print(f"Failed to connect to {device.name}: {e}")

Explanation by Line

Let’s decode the script section-wise:

Line NoExplanation
1Load pyATS’s YAML parser to read device info
4testbed.devices.values() gives all devices
5-6Display device name and OS
7.connect() initializes SSH connection
8If successful, prints version output
9Always disconnect after the session
10-11Handles SSH/auth errors gracefully

This lets you scale from 1 to 1000+ devices, with minimal code changes.


testbed.yml

Here’s your testbed file (save as testbed.yml):


testbed:
  name: MultiVendorLab
  credentials:
    default:
      username: admin
      password: password123

devices:
  R1:
    os: ios
    type: router
    connections:
      defaults:
        class: unicon.Unicon
      cli:
        protocol: ssh
        ip: 10.0.0.11

  SW1:
    os: eos
    type: switch
    connections:
      defaults:
        class: unicon.Unicon
      cli:
        protocol: ssh
        ip: 10.0.0.12

  FW1:
    os: fortinet
    type: firewall
    connections:
      defaults:
        class: unicon.Unicon
      cli:
        protocol: ssh
        ip: 10.0.0.13

  PA1:
    os: panos
    type: firewall
    connections:
      defaults:
        class: unicon.Unicon
      cli:
        protocol: ssh
        ip: 10.0.0.14

Multi-Vendor CLI

Below are real outputs from the .execute("show version") command:

Cisco IOS

Cisco IOS Software, IOSv Software (VIOS-ADVENTERPRISEK9-M), Version 15.6
...

Arista EOS

Arista vEOS version 4.26.1F
System MAC address: 52:54:00:11:22:33
...

FortiGate

FortiOS v6.2.3,build1066,191218 (GA)
Serial-Number: FGVM02TM20001234
...

Palo Alto

PAN-OS 10.2.0
Model: PA-VM
Serial: 0001C100000001
...

These outputs help verify SSH connectivity and the OS version remotely—one of the most common use cases.


FAQs

1. What if a device uses a different username/password?

Answer:
You can override the default credentials by specifying custom ones under the device block in testbed.yml.

2. Can this work without a testbed file?

Answer:
Yes, but not recommended. You’d need to create the testbed object in Python dynamically using Device() from unicon, which defeats the purpose of YAML modularity.

3. Why does FortiGate or Palo Alto sometimes refuse SSH?

Answer:
Ensure SSH is enabled under system settings. Also, these devices may need CLI access enabled for non-API users.

4. Is this script scalable to 100+ devices?

Answer:
Absolutely. You can add threading or asyncio for concurrency, especially useful for production-scale networks.

5. Can I parse command outputs like show ip route?

Answer:
Yes! Use device.parse() instead of device.execute() for structured data, provided the parser supports your vendor and command.

6. How do I debug failed SSH sessions?

Answer:
Use log_stdout=True or attach a debug log file. Ensure proper class and OS are mentioned in YAML.

7. Can I use Ansible instead of pyATS for this?

Answer:
Ansible works great for config pushes, but pyATS offers rich testing, parsing, and Python-native control.

8. What’s the benefit of Unicon over Paramiko/Netmiko?

Answer:
Unicon is tightly integrated with pyATS, handles state machines, better error handling, and supports Cisco/Arista/Palo as vendors.


YouTube Link

Watch the Complete Python for Network Engineer: Connecting to Cisco/Arista/Paloalto/Fortigate Devices (SSH) using pyATS for Cisco Lab Demo & Explanation on our channel:

Master Python Network Automation, Ansible, REST API & Cisco DevNet
Master Python Network Automation, Ansible, REST API & Cisco DevNet
Master Python Network Automation, Ansible, REST API & Cisco DevNet
Why Robot Framework for Network Automation?

Join Our Training

If you’re excited about automating your entire network—from SSH login to config parsing, testing, and CI/CD pipelines, then this is your next step:

Join Trainer Sagar Dhawan’s 3-Month Instructor-Led Training
Covering Python for Network Engineer, Ansible, REST APIs, Cisco DevNet, and of course, pyATS from zero to hero.

Click below to view course outline and enroll:

Enroll Now & Future‑Proof Your Career
Email: info@networkjourney.com
WhatsApp / Call: +91 97395 21088

https://course.networkjourney.com/python-ansible-api-cisco-devnet-for-network-engineers

Start automating your multi-vendor network with confidence.
Check the full course outline here: Course Link
Seats filling fast. Join now and future-proof your career.


Cisco DevNet training,Cisco Python scripts,Cisco SSH pyATS,multi-vendor network automation,network automation course India,PaloAlto SSH script,pyATS,pyATS testbed,python for network engineer,Python network CLI parsing,Python SSH multi-vendor,sagar dhawan training,SSH login automation,testbed.yml example,Unicon SSH connection
Share this post
Sagar Dhawan
Hi all, Good to see you here. I'm your Trainer for CCIE, CCNP, CCNA, Firewall batches and many more courses coming up! Stay tuned for latest updates! Keep me posted over Whatsapp/Email about your experience learning from us. Thanks for being part of - "Network Journey - A journey towards packet-life!!!"
[Day#4 PyATS Series] Creating Your First testbed.yaml (Multi-Vendor Testbed) using pyATS for Cisco
[DAY#6 PyATS Series] Using pyATS CLI tools: pyats learn, pyats parse using PyATS [Python for Network Engineer]

Related Posts

[Day #20 PyATS Series] Introduction to Verification APIs in pyATS using pyATS for Cisco [Python for Network Engineer]

  • Posted on September 6, 2025
  • [Day #84 PyATS Series] Multi-Vendor Golden Image Compliance Testing Using pyATS for Cisco [Python for Network Engineer]

    [Day #84 PyATS Series] Multi-Vendor Golden Image Compliance Testing Using pyATS for Cisco [Python for Network Engineer]

  • Posted on September 6, 2025
  • [Day #72 Pyats Series] Multi-vendor pre-change snapshot automation using pyATS for Cisco [Python for Network Engineer]

    [Day #72 Pyats Series] Multi-vendor pre-change snapshot automation using pyATS for Cisco [Python for Network Engineer]

  • Posted on September 6, 2025
  • Watch Free Playlist

    21 DAYS CCNA BOOTCAMPClick to Watch
    PYTHON3/ANSIBLE for NETWORK AUTOMATIONClick to Watch
    "FIREWALL MASTERY" : PA + FGT+ CP + ASA/FTD + F5 LTMClick to Watch
    OSPF+BGP+MPLSClick to Watch
    SDN ORCHESTRATIONClick to Watch

    Our Live Training

    PYTHON NETWORK AUTOMATIONRead Course Outline
    CCNA + CCNP ENTERPRISERead Course Outline
    CCNA to CCIE SECURITYRead Course Outline
    CISCO DEVNET + DEVCORRead Course Outline
    "MASTER CLOUD" : AZ700 + AWS + GCPRead Course Outline
    "FIREWALL MASTERY" : PA + FGT+ CP + ASA/FTD + F5 LTMRead Course Outline
    CISCO DNACRead Course Outline
    CISCO ISERead Course Outline
    MULTI-VENDOR TRAININGRead Course Outline
    SDN ORCHESTRATIONRead Course Outline
    • Basic Networking
    • CCNA 200-301
    • CCNA Security
    • CCNP Enterprise
    • Cisco Devnet
    • Cisco ISE
    • Education
    • GNS3 EVE-NG
    • Network Automation using Python3
    • Palo Alto Firewalls
    • PyATS
    • SD-ACCESS
    • SD-WAN

    CCNP Enterprise Massive Lab with 100+ Workbook

    https://youtu.be/NxifeWHzRvs

    Network Automation – Python3 & Ansible

    https://www.youtube.com/watch?v=PehVax3xxb0&t=782s

    Cisco ASA Firewall Training

    https://youtu.be/C8KLHpMe8nk

    Categories

    WANT TO ENROLL BUT NOT DECIDED YET?

    © 2019 - 2026 All rights reserved

    About Us

    Network Journey
    A journey towards packet life !!!

    We are the Top #1 Edtech platform providing student-satisfactory training on Cisco Networking, Security & Python Automation.

    Know More →

    Quick Links

    • About Us
    • Blog
    • All Courses
    • Self-Paced
    • Contact Us

    Support Links

    • CCIE ENTERPRISE INFRASTRUCTURE LAB : TRAINING
    • CCNP SUPER COMBO : ENCOR + ENARSI + SDWAN
    • Cisco SDWAN 300-415 {ENSDWI}

    Have Questions?

    Call us 24/7: +91-9739521088

    LinkedIn: NetworkJourney

    Email: info@networkjourney.com

    © 2023 Pixelcurve. All rights reserved.

    • Privacy Policy
    • Terms & Conditions
    • Refund Policy
    • Revision Policy
    WhatsApp us