From 388ce7ce8d37964da427d2430c9e03b14f790856 Mon Sep 17 00:00:00 2001 From: TheNotary Date: Mon, 16 Oct 2023 19:00:09 -0500 Subject: [PATCH] fix(provider): add informative error around ssh-agent (#620) * fix(provider): add informative error around ssh-agent Signed-off-by: TheNotary <799247+TheNotary@users.noreply.github.com> * fix linter errors Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> --------- Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> --- proxmox/ssh/client.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/proxmox/ssh/client.go b/proxmox/ssh/client.go index 00e70754..3e36d80e 100644 --- a/proxmox/ssh/client.go +++ b/proxmox/ssh/client.go @@ -159,7 +159,7 @@ func (c *client) NodeUpload( remoteFileDir = filepath.Join(remoteFileDir, d.ContentType) } - remoteFilePath := strings.ReplaceAll(filepath.Join(remoteFileDir, d.FileName), `\`, `/`) + remoteFilePath := strings.ReplaceAll(filepath.Join(remoteFileDir, d.FileName), `\`, "/") sftpClient, err := sftp.NewClient(sshClient) if err != nil { @@ -293,6 +293,12 @@ func (c *client) openNodeShell(ctx context.Context, node ProxmoxNode) (*ssh.Clie sshClient, err = ssh.Dial("tcp", sshHost, sshConfig) if err != nil { + if c.password == "" { + return nil, fmt.Errorf("unable to authenticate over SSH to %s. Please verify that ssh-agent is "+ + "correctly loaded with an authorized key via 'ssh-add -L' (NOTE: configurations in ~/.ssh/config are "+ + "not considered by golang's ssh implementation). The exact error from ssh.Dial: %w", sshHost, err) + } + return nil, fmt.Errorf("failed to dial %s: %w", sshHost, err) }