Skip to main content
Correct final bullet point and remove unneeded quotation marks
Source Link

I ended up creating a Bash script named sudo:

#!/usr/bin/env bash set -e console="$(tty)" readonly console /path/to/real/sudo -v # Sudo normally writes directly to the terminal device instead of # writing to stdout, so that’s what I’m doing here echo "AccessAccess granted." &> "$console" /path/to/real/sudo "$@" 

Then, I set my PATH to "/path/to/fake/sudo/dir:$PATH". There are a few limitations to this solution:

  • It won’t work properly if credential caching is disabled.
  • It will always prompt you forIf your passwordcredentials aren’t cached, even if you’re runningthen sudo --help or sudo -k will prompt for a password.

I ended up creating a Bash script named sudo:

#!/usr/bin/env bash set -e console="$(tty)" readonly console /path/to/real/sudo -v # Sudo normally writes directly to the terminal device instead of # writing to stdout, so that’s what I’m doing here echo "Access granted." &> "$console" /path/to/real/sudo "$@" 

Then, I set my PATH to "/path/to/fake/sudo/dir:$PATH". There are a few limitations to this solution:

  • It won’t work properly if credential caching is disabled.
  • It will always prompt you for your password, even if you’re running sudo --help or sudo -k.

I ended up creating a Bash script named sudo:

set -e console="$(tty)" readonly console /path/to/real/sudo -v # Sudo normally writes directly to the terminal device instead of # writing to stdout, so that’s what I’m doing here echo Access granted. &> "$console" /path/to/real/sudo "$@" 

Then, I set my PATH to "/path/to/fake/sudo/dir:$PATH". There are a few limitations to this solution:

  • It won’t work properly if credential caching is disabled.
  • If your credentials aren’t cached, then sudo --help or sudo -k will prompt for a password.
Source Link

I ended up creating a Bash script named sudo:

#!/usr/bin/env bash set -e console="$(tty)" readonly console /path/to/real/sudo -v # Sudo normally writes directly to the terminal device instead of # writing to stdout, so that’s what I’m doing here echo "Access granted." &> "$console" /path/to/real/sudo "$@" 

Then, I set my PATH to "/path/to/fake/sudo/dir:$PATH". There are a few limitations to this solution:

  • It won’t work properly if credential caching is disabled.
  • It will always prompt you for your password, even if you’re running sudo --help or sudo -k.