ingredient/ssh: Show ssh keys in info

This commit is contained in:
Tom Wiesing 2022-11-12 14:32:01 +01:00
parent 5bceaa0d47
commit e91e9cb4d6
No known key found for this signature in database
4 changed files with 41 additions and 0 deletions

View file

@ -8,6 +8,7 @@ import (
"github.com/FAU-CDI/wisski-distillery/pkg/environment"
"github.com/FAU-CDI/wisski-distillery/pkg/sshx"
"github.com/gliderlabs/ssh"
gossh "golang.org/x/crypto/ssh"
)
type SSH struct {
@ -30,3 +31,20 @@ func (ssh *SSH) Keys() ([]ssh.PublicKey, error) {
}
return sshx.ParseAllKeys(bytes), nil
}
func (sshx *SSH) Fetch(flags ingredient.FetchFlags, info *ingredient.Information) error {
if flags.Quick {
return nil
}
keys, err := sshx.Keys()
if err != nil {
return err
}
info.SSHKeys = make([]string, len(keys))
for i, key := range keys {
info.SSHKeys[i] = string(gossh.MarshalAuthorizedKey(key))
}
return nil
}

View file

@ -41,6 +41,9 @@ type Information struct {
// List of backups made
Snapshots []models.Export
// List of SSH Keys
SSHKeys []string
// WissKI content information
NoPrefixes bool // TODO: Move this into the database
Prefixes []string // list of prefixes