diff --git a/napalm_junos/junos.py b/napalm_junos/junos.py index bfb40fc..295f3f7 100644 --- a/napalm_junos/junos.py +++ b/napalm_junos/junos.py @@ -60,8 +60,9 @@ def __init__(self, hostname, username, password, timeout=60, optional_args=None) Initialise JunOS driver. Optional args: - * port (int): custom port * config_lock (True/False): lock configuration DB after the connection is established. + * port (int): custom port + * key_file (string): SSH key file path """ self.hostname = hostname self.username = username @@ -70,12 +71,21 @@ def __init__(self, hostname, username, password, timeout=60, optional_args=None) self.config_replace = False self.locked = False + # Get optional arguments if optional_args is None: optional_args = {} - self.port = optional_args.get('port', 22) + self.config_lock = optional_args.get('config_lock', True) + self.port = optional_args.get('port', 22) + self.key_file = optional_args.get('key_file', None) - self.device = Device(hostname, user=username, password=password, port=self.port) + if self.key_file: + self.device = Device(hostname, + user=username, + ssh_private_key_file=self.key_file, + port=self.port) + else: + self.device = Device(hostname, user=username, password=password, port=self.port) def open(self): """Open the connection wit the device."""