File: ssh_config_file.py

package info (click to toggle)
python-scrapli 2023.7.30-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,536 kB
  • sloc: python: 14,459; makefile: 72
file content (23 lines) | stat: -rw-r--r-- 730 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""examples.ssh_config_files.ssh_config_file"""
from scrapli.driver.core import IOSXEDriver

# setting `ssh_config_file` to True makes scrapli check in ~/.ssh/ and /etc/ssh/ for a file named
#  "config" or "ssh_config" respectively (standard openssh naming convention basically). You can
#  also just pass a path to a file of your choosing as we do here
MY_DEVICE = {
    "host": "172.18.0.11",
    "auth_strict_key": False,
    "ssh_config_file": "ssh_config",
}


def main():
    """Example demonstrating handling authentication/connection settings via ssh config file"""
    with IOSXEDriver(**MY_DEVICE) as conn:
        result = conn.send_command("show run")

    print(result.result)


if __name__ == "__main__":
    main()