Skip to content

Commit

Permalink
Print loaded keys on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
tlbdk committed Jan 30, 2020
1 parent 5952c2d commit 9b49a56
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"cloud.google.com/go/compute/metadata"
"github.com/connectedcars/auth-wrapper/gcemetadata"
"github.com/connectedcars/auth-wrapper/sshagent"
"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/agent"
)

Expand Down Expand Up @@ -100,6 +101,17 @@ func runWithSSHAgent(command string, args []string, sshKeyPath string, sshKeyPas
}
}

// Print loaded keys
keyList, err := sshAgent.List()
if err != nil {
return 1, fmt.Errorf("Failed to list sshAgent keys %s: %v", sshKeyPath, err)
}

fmt.Fprintf(os.Stderr, "Loaded keys:\n")
for _, key := range keyList {
fmt.Fprintf(os.Stderr, "%s\n", string(ssh.MarshalAuthorizedKey(key)))
}

sshAuthSock, err := sshagent.StartSSHAgentServer(sshAgent)
if err != nil {
return 1, fmt.Errorf("Failed to start ssh agent server: %v", err)
Expand Down

0 comments on commit 9b49a56

Please sign in to comment.