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

@ -63,6 +63,11 @@ func (i info) Run(context wisski_distillery.Context) error {
context.Printf("Last Update: %v\n", info.LastUpdate.String())
context.Printf("Last Cron: %v\n", info.LastCron.String())
context.Printf("SSH Keys: (count %d)\n", len(info.SSHKeys))
for _, key := range info.SSHKeys {
context.Printf("- %s\n", key)
}
context.Printf("Skip Prefixes: %v\n", info.NoPrefixes)
context.Printf("Prefixes: (count %d)\n", len(info.Prefixes))
for _, prefix := range info.Prefixes {

View file

@ -265,6 +265,21 @@
</div>
</div>
<div class="pure-u-1-1">
<h2 id="ssh">SSH Keys</h2>
<table class="pure-table pure-table-bordered padding">
<tbody>
{{ range .Info.Keys }}
<tr>
<td>
<code>{{ . }}</code>
</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
<div class="pure-u-1-1">
<h2 id="snapshots">Snapshots</h2>
<p>

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