Skip to content

Instantly share code, notes, and snippets.

@tdussa
tdussa / notify_new_login.sh
Last active July 4, 2024 10:00 — forked from arcticlinux/notify.sh
Email sysadmin on every login from a new IP address
#! /usr/bin/env bash
##
## New IP login notification script
## 2009-11-20 00:28 Samuele ~redShadow~ Santi
## 2018-06-04 12:53 ElliotNB
## 2018-10-17 17:55 ElliotNB - bug fixes for non-interactive sessions and `sudo su` commands
## 2019-08-27 16:15 mbest - update geoip lookup awk syntax, add mktemp for temporary directory,
## - add delete TMP_DIR function and trap to delete it for assurance,
## - change emails to example.com, add xargs to trim output
## 2024-06-10T08:25Z tdussa - Removed GeoIP lookup

Usage

Set up the host to connect to and port base to open:

export HOSTNAME=foo.bar
export JUMPHOST=jumphost.baz
export PORTBASE=1234

Create the autossh user: