From 38f1f2b2b6e1a387449d92d851885d25153e2ae1 Mon Sep 17 00:00:00 2001 From: Amogh Bharadwaj <65964360+Amogh-Bharadwaj@users.noreply.github.com> Date: Thu, 3 Oct 2024 19:45:33 +0530 Subject: [PATCH] SSH host key parsing: use ParseAuthorizedKey (#2125) `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 --- flow/connectors/utils/ssh.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flow/connectors/utils/ssh.go b/flow/connectors/utils/ssh.go index f9f83102ff..b3576ba486 100644 --- a/flow/connectors/utils/ssh.go +++ b/flow/connectors/utils/ssh.go @@ -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) }