Skip to content
Python library for Junos automation
Python Other
  1. Python 99.1%
  2. Other 0.9%
Branch: master
Clone or download
Latest commit 5b6c3a1 Jul 30, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs example for columns with multiple line. Jun 26, 2018
lib/jnpr Merge branch 'master' into vmhost-reboot-support Jul 30, 2019
static added PyEZ logo Jan 31, 2018
tests Merge branch 'master' into vmhost-reboot-support Jul 30, 2019
vagrant Update Mar 26, 2014
.coveragerc changing UT as per latest mock & coverage module Mar 7, 2017
.dockerignore inadvertently ignored requirements.txt...this is the fix May 8, 2018
.gitignore Update .gitignore to ignore desktop.ini, .DS_Store, and .idea files. Sep 14, 2016
.travis.yml Merge branch 'master' into vmhost-reboot-support Jul 30, 2019
COPYRIGHT init Oct 12, 2013 Removed sh as a CMD from Dockerfile and added Docker examples (#677) Mar 17, 2017
Dockerfile Replaced "python install" with "pip3 install" in Dockerfile Feb 13, 2019 Prepare release 2.1.0 (#689) Mar 23, 2017 Update Jun 1, 2018 Added OS X INSTALL and updated README May 7, 2014 Prepare release 2.1.0 (#689) Mar 23, 2017
LICENSE Update LICENSE Oct 3, 2018 added requirements.txt for package distribution Apr 18, 2014 Merge pull request #904 from webberist/patch-1 Jul 25, 2019
README.txt fix for pypi upload Nov 29, 2013 Update PyEZ version: 2.2.1 Apr 22, 2019
development.txt changing UT as per latest mock & coverage module Mar 7, 2017
docreq.txt Req file for docs Jun 19, 2014 updates Mar 17, 2014
requirements.txt Merge branch 'master' of int… Mar 19, 2019 Merge branch 'master' into vmhost-reboot-support Jul 30, 2019

PyPi Version Documentation Status Coverage Status UnitTest Status

The repo is under active development. If you take a clone, you are getting the latest, and perhaps not entirely stable code.


Official Documentation with examples, here

API Documentation hosted by readthedocs

Junos PyEZ wiki page, here.


PyEZ logo

Junos PyEZ is a Python library to remotely manage/automate Junos devices. The user is NOT required: (a) to be a "Software Programmer™", (b) have sophisticated knowledge of Junos, or (b) have a complex understanding of the Junos XML API.

This library was built for two types of users:

For "Non-Programmers" - Python as a Power Shell

This means that "non-programmers", for example the Network Engineer, can use the native Python shell on their management server (laptop, tablet, phone, etc.) as their point-of-control for remotely managing Junos devices. The Python shell is an interactive environment that provides the necessary means to perform common automation tasks, such as conditional testing, for-loops, macros, and templates. These building blocks are similar enough to other "shell" environments, like Bash, to enable the non-programmer to use the Python shell as a power-tool, rather than a programming language. From the Python shell a user can manage Junos devices using native hash tables, arrays, etc. rather than device-specific Junos XML or resorting to 'screen scraping' the actual Junos CLI.

For "Programmers" - Open and Extensible

There is a growing interest and need to automate the network infrastructure into larger IT systems. To do so, traditional software programmers, DevOps, "hackers", etc. need an abstraction library of code to further those activities. Junos PyEZ is designed for extensibility so that the programmer can quickly and easily add new widgets to the library in support of their specific project requirements. There is no need to "wait on the vendor" to provide new functionality. Junos PyEZ is not specifically tied to any version of Junos or any Junos product family.


For questions and general support, please visit our Google Group

You can also post your query on stackoverflow with pyez tag

For documentation and more usage examples, please visit the Junos PyEZ project page, here.

Issues and bugs can be opened in the repository.


Junos PyEZ is designed to provide the same capabilities as a user would have on the Junos CLI, but in an environment built for automation tasks. These capabilities include, but are not limited to:

  • Remote connectivity and management of Junos devices via NETCONF
  • Provide "facts" about the device such as software-version, serial-number, etc.
  • Retrieve "operational" or "run-state" information as Tables/Views
  • Retrieve configuration information as Tables/Views
  • Make configuration changes in unstructured and structured ways
  • Provide common utilities for tasks such as secure copy of files and software updates


  • As of release 2.0.0, Junos PyEZ requires ncclient version 0.5.2 or later.
  • When using the ssh_private_key_file argument of the Device constructor on MacOS Mojave and higher, ensure that the SSH keys are in the RSA format, and not the newer OPENSSH format.
    • New key: ssh-keygen -p -m PEM -f ~/.ssh/id_rsa
    • Convert an existing OPENSSH key: ``ssh-keygen -p -m PEM -f ~/.ssh/private_key`
    • Check if a given key is RSA or OPENSSH format: head -n1 ~/.ssh/private_key
      • RSA: -----BEGIN RSA PRIVATE KEY-----



Installation requires Python 2.7 or >=3.4 and associated pip tool

pip install junos-eznc

Installing from Git is also supported (OS must have git installed).

To install the latest MASTER code
pip install git+
To install a specific version, branch, tag, etc.
pip install git+<branch,tag,commit>


Move to the local directory which contains your script(s) and run the container

docker run -it --rm --name pyez -v "$(pwd)":/scripts juniper/pyez sh

Your local scripts will be mounted to /scripts in the container

cd scripts

See for some example usage.


Upgrading has the same requirements as installation and has the same format with the addition of -UPGRADE

pip install -U junos-eznc


The following is a quick "hello, world" example to ensure that the software was installed correctly. This code will simply connect to a device and display the known facts of the device, like serial-number, model, etc.

from pprint import pprint
from jnpr.junos import Device

with Device(host='my_host_or_ipaddr', user='jeremy', password='jeremy123' ) as dev:
    pprint( dev.facts )

Example output for an SRX-210 device:

>>> pprint(dev.facts)
{'2RE': False,
 'RE0': {'last_reboot_reason': '0x20:power-button soft power off',
         'model': 'RE-SRX210H',
         'status': 'OK',
         'up_time': '10 minutes, 3 seconds'},
 'domain': ''         
 'fqdn': '',
 'hostname': 'srx210',
 'ifd_style': 'CLASSIC',
 'model': 'SRX210H',
 'personality': 'SRX_BRANCH',
 'serialnumber': 'AD2909AA0096',
 'switch_style': 'VLAN',
 'version': '12.1X44-D10.4',
 'version_info': junos.versino_info(major=(12, 1), type=X, minor=(44, 'D', 10), build=4)}


Apache 2.0


Juniper Networks is actively contributing to and maintaining this repo. Please contact for any queries.


Nitin Kumar, Stacy Smith, Stephen Steiner

Former Contributors:

Jeremy Schulman, Rick Sherman, Edward Arcuri

You can’t perform that action at this time.