Skip to content

Instantly share code, notes, and snippets.

@rdkls
Created September 6, 2018 12:20
Show Gist options
  • Save rdkls/f7dcf9db767d435c602f1dddd297e921 to your computer and use it in GitHub Desktop.
Save rdkls/f7dcf9db767d435c602f1dddd297e921 to your computer and use it in GitHub Desktop.
ncclient demo
#!/usr/bin/env python
import ncclient.manager
import lxml
host = 'ios-xe-mgmt.cisco.com'
ssh_port = 8181
netconf_port = 10000
username = 'root'
password = 'D_Vay!_10&'
host_key_b64 = 'AAAAB3NzaC1yc2EAAAADAQABAAABAQDKwtRsDG4PpErhl0orhYZ6GLb/xPk81hUm7QWDMbAt3BKz1GrTnbZ0VZjmDE/joXVs6cNt9UvFvpVymwbx2IdqY9qN4DrWpZtzQ4l1asgcGGVbzX0wj2r6ZJbm9AhPW9WDZ4Ke/Hwbs/MxxKkEuQYRJekfnFTO1zRu1xyptwuLCS6P+Y79W+EiFLV8/9jZHjRlcpD+Fi4K0NSluDOrXw6Zn5XqXPSAYYkAOQnFGTfZuOGu5iyK1KVEGO7YS1WCAqnmyVF1RqJI1ehEUqjhqd8UYlD0Uq7KlPuA+EIzsDdEZ9vhMEbPBf0tgh9Lt+3UaTFNTGsdoDSdWuM13v+BR463'
with ncclient.manager.connect_ssh(host=host, port=netconf_port, username=username, password=password, hostkey_verify=True, hostkey=host_key_b64) as m:
c = m.get_config(source='running').data_xml
print(c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment