netmiko使用案例10 ssh_config文件模式登陆思科设备

conn_ssh_proxy.py

#!/usr/bin/env python
from netmiko import Netmiko
from getpass import getpass

key_file = "/home/gituser/.ssh/test_rsa"

cisco1 = {
    'device_type': 'cisco_ios',
    'host': 'cisco1.twb-tech.com', 
    'username': 'testuser',
    'use_keys': True,
    'key_file': key_file,
    'ssh_config_file': './ssh_config',
}

net_connect = Netmiko(**cisco1)
print(net_connect.find_prompt())
output = net_connect.send_command("show ip arp")
print(output)


ssh_config

host jumphost
  IdentityFile ~/.ssh/test_rsa
  user gituser
  hostname 54.241.72.159

host * !jumphost
  ProxyCommand ssh jumphost nc %h %p

你可能感兴趣的:(netmiko使用案例10 ssh_config文件模式登陆思科设备)