Skip to content

Commit

Permalink
feat: display SHA256 fingerprint in userkey ls output
Browse files Browse the repository at this point in the history
This help a bit when wanting a list of SSH keys associated to a user

ssh -p 2222 sshportal@localhost userkey ls | grep <USER>
  • Loading branch information
libvoid committed Sep 7, 2023
1 parent e8fd4f7 commit 04aff84
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/bastion/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -2231,21 +2231,28 @@ GLOBAL OPTIONS:
}

table := tablewriter.NewWriter(s)
table.SetHeader([]string{"ID", "User", "Updated", "Created", "Comment"})
table.SetHeader([]string{"ID", "User", "Updated", "Created", "Comment", "Fingerprint"})
table.SetBorder(false)
table.SetCaption(true, fmt.Sprintf("Total: %d userkeys.", len(userKeys)))
for _, userkey := range userKeys {
email := naMessage
if userkey.User != nil {
email = userkey.User.Email
}

pubUserkey, err := gossh.ParsePublicKey(userkey.Key)
if err != nil {
return err
}

table.Append([]string{
fmt.Sprintf("%d", userkey.ID),
email,
// FIXME: add fingerprint
humanize.Time(userkey.UpdatedAt),
humanize.Time(userkey.CreatedAt),
userkey.Comment,
gossh.FingerprintSHA256(pubUserkey),
})
}
table.Render()
Expand Down

0 comments on commit 04aff84

Please sign in to comment.