У меня есть настройка cron для резервного копирования каждое утро и отправки по электронной почте на мою учетную запись Gmail, и она прекрасно работает. Противный побочный эффект - всякий раз, когда я неправильно набираю свой пароль с помощью sudo, я также получаю электронное письмо, которое раздражает: погуглил немного, но не могу узнать, как отключить эту функцию электронной почты.
/etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
Из man sudoers
:
mail_badpass Send mail to the mailto user if the user running sudo
does not enter the correct password. If the command
the user is attempting to run is not permitted by
sudoers and one of the mail_all_cmnds, mail_always,
mail_no_host, mail_no_perms or mail_no_user flags are
set, this flag will have no effect. This flag is off
by default.
По умолчанию этот флаг отключен, но, как вы заметили, он включен в файле / etc / sudoers Ubuntu по умолчанию.
Предположительно, вы начали получать эти сообщения, потому что sudoers
по умолчанию mailto
- root
- и вы настроили MTA для доставки почты root для cron
. Сообщения должны прекратиться, если вы закомментируете строку Defaults mail_badpass
(используя sudo visudo
).