From 63a6343c2dedb907f5b76307d27e8bb5687f05f3 Mon Sep 17 00:00:00 2001 From: Ayrris Aunario Date: Thu, 4 Apr 2024 14:33:16 -0500 Subject: [PATCH] `ssh` / `list` improvements: 1) support for SSH using "pamMachine" records 2) improved "pamMachine" record description (now includes username and host) --- keepercommander/commands/base.py | 4 ++-- keepercommander/commands/connect.py | 5 +++-- keepercommander/vault_extensions.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/keepercommander/commands/base.py b/keepercommander/commands/base.py index 228434ffe..a5b193031 100644 --- a/keepercommander/commands/base.py +++ b/keepercommander/commands/base.py @@ -676,8 +676,8 @@ def get_record_field(record, field_name): # type: (vault.KeeperRecord, str) return record.link elif isinstance(record, vault.TypedRecord): - if field_name in {'hostname', 'port'}: - field = record.get_typed_field('host') + if field_name in {'hostname', 'port', 'host'}: + field = record.get_typed_field('host') or record.get_typed_field('pamHostname') else: field = record.get_typed_field(field_name) if field: diff --git a/keepercommander/commands/connect.py b/keepercommander/commands/connect.py index a8dce2534..7c25d0feb 100644 --- a/keepercommander/commands/connect.py +++ b/keepercommander/commands/connect.py @@ -231,10 +231,11 @@ def get_parser(self): return ssh_parser def execute(self, params, **kwargs): + ssh_record_types = ['serverCredentials', 'sshKeys', 'pamMachine'] record_name = kwargs['record'] if 'record' in kwargs else None if not record_name: ls = RecordListCommand() - return ls.execute(params, record_type=['serverCredentials', 'sshKeys'], verbose=True, **kwargs) + return ls.execute(params, record_type=ssh_record_types, verbose=True, **kwargs) record = None # type: Optional[KeeperRecord] if record_name in params.record_cache: @@ -255,7 +256,7 @@ def execute(self, params, **kwargs): if record is None: ls = RecordListCommand() - result = ls.execute(params, record_type=['serverCredentials', 'sshKeys'], format='json', verbose=True) + result = ls.execute(params, record_type=ssh_record_types, format='json', verbose=True) if result: try: recs = json.loads(result) diff --git a/keepercommander/vault_extensions.py b/keepercommander/vault_extensions.py index a230a3d5e..6192b3aa5 100644 --- a/keepercommander/vault_extensions.py +++ b/keepercommander/vault_extensions.py @@ -107,7 +107,7 @@ def get_record_description(record): # type: (vault.KeeperRecord) -> Optional[s if field: comps.append(field.get_default_value()) else: - field = next((x for x in record.fields if x.type == 'host'), None) + field = next((x for x in record.fields if x.type.lower() in {'host', 'pamhostname'}), None) if field: host = field.get_default_value() if isinstance(host, dict):