{"record":{"id":"f8a3d9447490d26f","repo":"semaphoreui/semaphore","slug":"parsing-private-key-w","errorCode":null,"errorMessage":"parsing private key: %w","messagePattern":"parsing private key: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/ssh/agent.go","lineNumber":52,"sourceCode":"}\n\nfunc (a *Agent) Listen() error {\n\tkeyring := agent.NewKeyring()\n\n\tfor _, k := range a.Keys {\n\t\tvar (\n\t\t\tkey any\n\t\t\terr error\n\t\t)\n\n\t\tif len(k.Passphrase) == 0 {\n\t\t\tkey, err = ssh.ParseRawPrivateKey(k.Key)\n\t\t} else {\n\t\t\tkey, err = ssh.ParseRawPrivateKeyWithPassphrase(k.Key, k.Passphrase)\n\t\t}\n\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"parsing private key: %w\", err)\n\t\t}\n\n\t\tif err := keyring.Add(agent.AddedKey{\n\t\t\tPrivateKey: key,\n\t\t}); err != nil {\n\t\t\treturn fmt.Errorf(\"adding private key: %w\", err)\n\t\t}\n\t}\n\n\tif err := os.MkdirAll(path.Dir(a.SocketFile), 0o755); err != nil {\n\t\treturn fmt.Errorf(\"creating socket directory: %w\", err)\n\t}\n\n\tl, err := net.ListenUnix(\n\t\t\"unix\",\n\t\t&net.UnixAddr{\n\t\t\tNet:  \"unix\",\n\t\t\tName: a.SocketFile,","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/semaphoreui/semaphore/blob/1774ccb71a0a8b82eb74ea24c23ac9ab713de2fa/pkg/ssh/agent.go#L34-L70","documentation":"Returned by Agent.Listen in pkg/ssh/agent.go when golang.org/x/crypto/ssh fails to parse one of the configured private keys. ParseRawPrivateKey (or the WithPassphrase variant when a passphrase is present) rejects the key bytes, meaning the PEM/OpenSSH blob is malformed, truncated, in an unsupported format, or the passphrase is wrong. The %w wraps the underlying x/crypto error which carries the precise cause.","triggerScenarios":"Thrown at pkg/ssh/agent.go:52 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the key material is a complete, unmodified PEM or OpenSSH private key block (check BEGIN/END lines and base64 body)","If the key is encrypted, confirm the passphrase stored with the access key matches the one used to encrypt it","Re-export the key in OpenSSH or PKCS#1/PKCS#8 PEM format that x/crypto/ssh supports and update the stored key","Inspect the wrapped error string (ssh: this private key is passphrase protected / no key found / decode error) to pinpoint whether it is a format or passphrase problem"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1774ccb71a0a8b82eb74ea24c23ac9ab713de2fa","analyzedAt":"2026-09-07T11:00:33.293Z","contentChangedAt":"2026-09-07T11:00:33.293Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}