๐Ÿง How to set up a sudo password prompt

How to make a warning when entering sudo

You probably have several admins running your Linux servers.

To actually do anything, these admins will most likely have to use sudo.

As you probably well know, you can do anything with your servers with sudo.

Therefore, make sure your admins use sudo with caution.

One way to do this is by setting up a sudo password prompt.

So, instead of sudo just asking for the admin password, it also warns them to be careful.

Let’s say, for example, when you have a user running sudo, you want the password prompt to say “WARNING – THINK WHAT YOU ARE DOING -> PASSWORD:”

You can make this configuration change with one quick command. On completion, when the user enters the command with sudo, they will be presented with this warning.

To do this, open a terminal window and install a custom prompt using the command:

export SUDO_PROMPT="Custom Prompt"

Custom Prompt is the text string that we will use for the sudo warning. Following our example above, this command will:

export SUDO_PROMPT="ะ’ะะ˜ะœะะะ˜ะ• - ะ”ะฃะœะะ™ ะงะขะž ะ”ะ•ะ›ะะ•ะจะฌ - > ะŸะะ ะžะ›ะฌ:"

Once you do this, the user will see this warning whenever they use sudo.

If you ever decide to change this, you can simply rerun the command with a different line with the desired value.

If you want to revert this to the default values, run the command:

unset SUDO_PROMPT

And that’s all it takes to set up a sudo password prompt. This is a very easy way to remind administrators to be careful with sudo. After all, no one wants to fix mistakes at this level.

Sidebar