Skip to content

Commit

Permalink
SSH host key parsing: use ParseAuthorizedKey (#2125)
Browse files Browse the repository at this point in the history
`ParsePublicKey` expects the public key in a different SSH wire protocol
format while `ParseAuthorizedKey` expects what you see in an
`id_rsa.pub` file (which gives an error - `short read` when trying to
parse it with `ParsePublicKey`)


References:
-
[ParsePublicKey](https://pkg.go.dev/golang.org/x/crypto/ssh#ParsePublicKey)
-
[ParseAuthorizedKey](https://pkg.go.dev/golang.org/x/crypto/ssh#ParseAuthorizedKey)

- [x] Functionally tested
  • Loading branch information
Amogh-Bharadwaj authored Oct 3, 2024
1 parent 79cd46e commit 38f1f2b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion flow/connectors/utils/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func GetSSHClientConfig(config *protos.SSHConfig) (*ssh.ClientConfig, error) {

var hostKeyCallback ssh.HostKeyCallback
if config.HostKey != "" {
pubKey, err := ssh.ParsePublicKey([]byte(config.HostKey))
pubKey, _, _, _, err := ssh.ParseAuthorizedKey([]byte(config.HostKey))
if err != nil {
return nil, fmt.Errorf("failed to parse host key: %w", err)
}
Expand Down

0 comments on commit 38f1f2b

Please sign in to comment.