--- Helper functions --- listImportedKeys lists all imported private keys
()
| 561 | |
| 562 | // listImportedKeys lists all imported private keys |
| 563 | func 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 |
| 587 | func reloadHosts(ctx *ShellContext) error { |