Skip to content

Commit

Permalink
ssh / list improvements: 1) support for SSH using "pamMachine" re…
Browse files Browse the repository at this point in the history
…cords 2) improved "pamMachine" record description (now includes username and host)
  • Loading branch information
aaunario-keeper authored and sk-keeper committed Apr 4, 2024
1 parent 6720f71 commit 63a6343
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions keepercommander/commands/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions keepercommander/commands/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion keepercommander/vault_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 63a6343

Please sign in to comment.