Skip to content

Commit

Permalink
Merge pull request #15513 from kaylendog/master
Browse files Browse the repository at this point in the history
Add groups check to SSH driver
  • Loading branch information
medyagh committed Dec 21, 2022
2 parents 69757f6 + 24428fd commit f80c39c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/drivers/ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"os/exec"
"path"
"strconv"
"strings"
"time"

"golang.org/x/crypto/ssh"
Expand Down Expand Up @@ -141,8 +142,14 @@ func (d *Driver) Create() error {
}

if d.runtime.Name() == "Docker" {
if _, err := d.exec.RunCmd(exec.Command("sudo", "usermod", "-aG", "docker", d.GetSSHUsername())); err != nil {
return errors.Wrap(err, "usermod")
groups, err := d.exec.RunCmd(exec.Command("groups", d.GetSSHUsername()))
if err != nil {
return errors.Wrap(err, "groups")
}
if !strings.Contains(groups.Stdout.String(), "docker") {
if _, err := d.exec.RunCmd(exec.Command("sudo", "usermod", "-aG", "docker", d.GetSSHUsername())); err != nil {
return errors.Wrap(err, "usermod")
}
}
}

Expand Down

0 comments on commit f80c39c

Please sign in to comment.