Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: default ~/.ssh/id_rsa key not loaded
Fix typo in default configs loading.

Signed-off-by: Timofey Kirillov <timofey.kirillov@flant.com>
  • Loading branch information
distorhead committed Mar 15, 2022
1 parent c76ddfc commit 2c186fe
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/ssh_agent/ssh_agent.go
Expand Up @@ -128,17 +128,17 @@ func Init(ctx context.Context, userKeys []string) error {
return nil
}

var defaultConfigs []*sshKeyConfig
var defaultConfigs []sshKeyConfig
for _, defaultFileName := range []string{"id_rsa", "id_dsa"} {
path := filepath.Join(os.Getenv("HOME"), ".ssh", defaultFileName)

if keyExists, _ := util.FileExists(path); keyExists {
defaultConfigs = append(defaultConfigs, &sshKeyConfig{FilePath: path})
defaultConfigs = append(defaultConfigs, sshKeyConfig{FilePath: path})
}
}

if len(defaultConfigs) > 0 {
keys, err := loadSshKeys(ctx, configs, loadSshKeysOptions{WarnInvalidKeys: true})
keys, err := loadSshKeys(ctx, defaultConfigs, loadSshKeysOptions{WarnInvalidKeys: true})
if err != nil {
return fmt.Errorf("unable to load ssh keys: %s", err)
}
Expand Down

0 comments on commit 2c186fe

Please sign in to comment.