Fix domain

This commit is contained in:
Max Isom 2016-09-16 11:56:05 -05:00 committed by GitHub
parent ba5417bcff
commit 69394a563b
1 changed files with 7 additions and 18 deletions

View File

@ -1,28 +1,17 @@
function get_default_hostname { source /etc/mailinabox.conf # load global vars
# Guess the machine's hostname. It should be a fully qualified
# domain name suitable for DNS. None of these calls may provide
# the right value, but it's the best guess we can make.
set -- $(hostname --fqdn 2>/dev/null ||
hostname --all-fqdns 2>/dev/null ||
hostname 2>/dev/null)
printf '%s\n' "$1" # return this value
}
echo ' cat <<EOF >> /etc/ssh/login-alert.sh
#!/bin/sh #!/bin/sh
# Change these two lines: sender="bot@PRIMARY_HOSTNAME"
sender="bot@" recepient="admin@$PRIMARY_HOSTNAME"
sender+=get_default_hostname
recepient="admin@"
recepient+=get_default_hostname
if [ "$PAM_TYPE" != "close_session" ]; then if [ "$PAM_TYPE" != "close_session" ]; then
host="`hostname`" subject="SSH Login: $PAM_USER from $PAM_RHOST"
subject="SSH Login: $PAM_USER from $PAM_RHOST on $host"
# Message to send, e.g. the current environment variables. # Message to send, e.g. the current environment variables.
message="If you don't recognize this login, your key or password may be compromised." message="If you don't recognize this login, your key or password may be compromised."
echo "$message" | mailx -r "$sender" -s "$subject" "$recepient" echo "$message" | mailx -r "$sender" -s "$subject" "$recepient"
fi' > /etc/ssh/login-alert.sh fi
EOF
chmod +x /etc/ssh/login-alert.sh chmod +x /etc/ssh/login-alert.sh