Kainé on Nostr: How... can I switch to the root user with sudo in #bash while reading the password ...
How... can I switch to the root user with sudo in #bash while reading the password from a variable?
These don't work:
echo "$sudo_password" | sudo -S su -
# or
echo "$sudo_password" | sudo -S -i
I've also verified that the password (var) being passed should be correct. If I enter the password manually, interactively, the commands work:
sudo su -
# or
sudo -i
Published at
2024-07-03 19:56:32Event JSON
{
"id": "969cbb051768a3142285a4df689c0758287983fa30108b77388f39e0c545f549",
"pubkey": "6dfc539e165eb2e7f341413bcb7b2349bdb6c9e88e121b3e9172265df202517d",
"created_at": 1720036592,
"kind": 1,
"tags": [
[
"t",
"bash"
],
[
"proxy",
"https://sakurajima.social/notes/9v9tou1uok",
"activitypub"
]
],
"content": "How... can I switch to the root user with sudo in #bash while reading the password from a variable?\n\nThese don't work:\n\n\necho \"$sudo_password\" | sudo -S su -\n# or\necho \"$sudo_password\" | sudo -S -i\nI've also verified that the password (var) being passed should be correct. If I enter the password manually, interactively, the commands work:\n\n\nsudo su -\n# or\nsudo -i",
"sig": "1825d1abb5ab5977086b83da1ca88a0fab1bcb2184b0f7037354b75bbc888e6df49ab93de92e8b3a9ee3616bc343fe897ab88dac445ba86897e3d3ece0825b58"
}