MCPcopy Create free account
hub / github.com/Mister-leo/fssh / listImportedKeys

Function listImportedKeys

cmd/fssh/shell_commands.go:563–584  ·  view source on GitHub ↗

--- Helper functions --- listImportedKeys lists all imported private keys

()

Source from the content-addressed store, hash-verified

561
562// listImportedKeys lists all imported private keys
563func listImportedKeys() ([]string, error) {
564 dir := store.KeysDir()
565 entries, err := os.ReadDir(dir)
566 if err != nil {
567 if os.IsNotExist(err) {
568 return []string{}, nil
569 }
570 return nil, err
571 }
572
573 var keys []string
574 for _, e := range entries {
575 if e.IsDir() || !strings.HasSuffix(e.Name(), ".enc") {
576 continue
577 }
578 // Remove .enc suffix to get alias
579 alias := strings.TrimSuffix(e.Name(), ".enc")
580 keys = append(keys, alias)
581 }
582
583 return keys, nil
584}
585
586// reloadHosts reloads host information into the context
587func reloadHosts(ctx *ShellContext) error {

Callers 1

runShellFunction · 0.85

Calls 1

KeysDirFunction · 0.92

Tested by

no test coverage detected