Skip to content

Commit

Permalink
Use sudo -S argument to pipe in password
Browse files Browse the repository at this point in the history
  • Loading branch information
jpm-canonical committed Aug 30, 2024
1 parent c3a48b6 commit 45949a3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/thread_tests/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ func remote_exec(t *testing.T, command string) string {

t.Logf("[exec-ssh] %s", command)

// Remote commands that require sudo might ask for the password. Always pass it in. See https://stackoverflow.com/a/11955358
if strings.HasPrefix(command, "sudo ") {
command = command[5:] // remove "sudo "
command = "echo \"" + remotePassword + "\" | sudo -S " + command
}

if SSHClient == nil {
t.Fatalf("SSH client not initialized. Please connect to remote device first")
}
Expand Down

0 comments on commit 45949a3

Please sign in to comment.