From 1f333ea097f43097e3847d08153145ac2a44faad Mon Sep 17 00:00:00 2001 From: Pavel Boldyrev <627562+bpg@users.noreply.github.com> Date: Sun, 28 Jan 2024 12:13:43 -0500 Subject: [PATCH] fix(vm): error when creating custom disks on PVE with non-default shell (#983) Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> --- proxmox/ssh/client.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/proxmox/ssh/client.go b/proxmox/ssh/client.go index 30f7adc3..353c4da9 100644 --- a/proxmox/ssh/client.go +++ b/proxmox/ssh/client.go @@ -119,7 +119,16 @@ func (c *client) ExecuteNodeCommands(ctx context.Context, nodeName string, comma defer closeOrLogError(sshSession) - output, err := sshSession.CombinedOutput(strings.Join(commands, "; ")) + script := strings.Join(commands, "; ") + + output, err := sshSession.CombinedOutput( + fmt.Sprintf( + // explicitly use bash to support shell features like pipes and var assignment + "/bin/bash -c '%s'", + // shell script escaping for single quotes + strings.ReplaceAll(script, `'`, `'"'"'`), + ), + ) if err != nil { return nil, errors.New(string(output)) }