I have given the reboot command unexpectedly,to prevent this issue need to assign password confirmation for shutdown or reboot activities even though logging as root.Kindly suggest to prevent this issue.Thanks in advance.
2 Answers
A solution for your request was found here
In the root .bash_profile, setup two aliases like:
alias shutdown='/usr/local/bin/confirm shutdown'
alias reboot='/usr/local/bin/confirm reboot'
With /usr/local/bin/confirm being something like:
#!/bin/bash
echo "Before proceeding to perform $1, please ensure you have approval to perform this task"
echo -n "Would you like to proceed y/n? "
read reply
if [ "$reply" = y -o "$reply" = Y ]
then
/sbin/$1
else
echo "$1 cancelled"
fi
Notes:
- You can replace the
yrespond with your password- You can use shell-compiler to replace the shell script with a compiled code which won't expose the password
- 4,289
Does it need to be a password?
http://manpages.ubuntu.com/manpages/trusty/man8/molly-guard.8.html
molly-guard was primarily designed to shield SSH connections. This functionality (which should arguably be provided by the openssh-server package) is implemented in /etc/molly-guard/run.d/30-query-hostname.
This script first tests whether the command is being executed from a tty which has been created by sshd. It also checks whether the variable SSH_CONNECTION is defined. If any of these tests are successful, test script queries the user for the machine's hostname, which should be sufficient to prevent the user from doing something by accident.
and
setting ALWAYS_QUERY_HOSTNAME in /etc/molly-guard/rc causes the script to always query.
- 50,249