I have a shell script that runs on a freebsd OS. the script has some commands that needs the sudo privileges
Im excuting the script remotley and it's skipping the sudo commands
i tried the following :
echo password | sudo -S Command
but it's not doing anything (same results)
note : i can't modify the sudoers file because it's an automated process that creates a virtual machine and excute the script once it's created
I'm usign posh-ssh to excute the script remotely :
#Excute Script
$ExShellScript = 'echo "password" | sudo -S sh script.sh
Write-Output $ExShellScript
$Query2 = $(Invoke-SshCommand -SSHSession $SessionID -Command $ExShellScript).Output
$Query2 = $Query2.split("`n")
Write-Output $Query2
Remove-SSHSession -Name $SessionID | Out-Null
i would apreciate it if someone could guide me to the right direction because im stuck here.
root
, but lose privileges usingsudo(8)
whenroot
isn’t required? This won’t require setting up a propersudoers(5)
file.