Ichimusai

Ichimusai

Sök
Hoppa till innehåll
  • Ichimusai
  • LaTeX Typesetting
  • Projects
    • Home Studio
    • Albin Tenglet
      • Ristning: Ala Senti
      • Ristning: Ture Vännen
    • Exkursioner
    • Excursions
    • ipta – IPTables log analyzer
    • Emacs Resources
    • Checklists
    • Mâlungsmål
    • Photo challenges
    • Running Project
    • Spotify Playlists
English

Ubuntu Login-Notify

2024-06-30 Ichimusai

This is a useful hack for VPS servers to send an email as a login-notify to an email address.

Prerequisites

You need to have a working mail subsystem on your host so that the mail command works.

This works with Ubuntu 22.04 and later versions.

Modify PAM to notify on login

Open the file /etc/pam.d/common-session and at the bottom add the following line:

session optional pam_exec.so /root/script/login-notify

Login-Notify script

Create the following script in /root/script/login-notify

#!/bin/bash                                                                                
                                                                                           
#                                                                                          
# This script is run by PAM from /etc/pam.d/common-session by adding the following         
# line to the bottom of the configuration file:                                            
#                                                                                          
# session optional pam_exec.so /root/script/login-notify                                   
#                                                                                          
# Make sure the script is executeable                                                      
#                                                                                          
# ichi@ichimusai.org                                                                       
# Revision 1.0.0                                                                           
#                                                                                          
                                                                                           
                                                                                           
[ "$PAM_TYPE" = "open_session" ] || exit 0                                                 
{                                                                                          
    echo "User:    $PAM_USER"                                                              
    echo "Ruser:   $PAM_RUSER"                                                             
    echo "Rhost:   $PAM_RHOST"                                                             
    echo "Service: $PAM_SERVICE"                                                           
    echo "TTY:     $PAM_TTY"                                                               
    echo "Date:    `date +"%y%m%d-%H%M%S"`"                                                
    echo "Server:  `hostname -s`"                                                          
} | mail -s "[`hostname -s`] $PAM_SERVICE login: $PAM_USER" anders@sikvall.se &                                                                                

This script will now be executed upon login and should send an email to the recipient with login matters.

common-sessionetclinuxloginlogin-notifypamrootscriptscriptingshellVPS

Inläggsnavigering

Föregående inläggSet netplan to use network-managerNästa inläggSetting up MSMTP for Protonmail

Photos and other rants

  • Ichimusai
  • LaTeX Typesetting
  • Projects
    • Home Studio
    • Albin Tenglet
      • Ristning: Ala Senti
      • Ristning: Ture Vännen
    • Exkursioner
    • Excursions
    • ipta – IPTables log analyzer
    • Emacs Resources
    • Checklists
    • Mâlungsmål
    • Photo challenges
    • Running Project
    • Spotify Playlists

Meta

  • Logga in
  • Flöde för inlägg
  • Flöde för kommentarer
  • WordPress.org

Kategorier

  • English
  • Swedish
  • Uncategorized

Blogs I Like

  • Fordonsradio
  • Fotonen
  • Groovy Nut
  • La Donna
  • Ondskan
  • Photos from Haninge
  • Sue Ellen

LaTeX Typesetting System

  • CTAN Archives all things TeX
  • IDVI – View DVI files
  • LaTeX – a document preparation system
  • LaTeX Help
  • LaTeX Wikipedia Entry
  • LC – LaTeX Community
  • PC-TeX
  • TeX FAQ
  • The not so short LaTeX introduction
  • Using true type fonts with LaTeX
  • Word processors and LaTeX

Links

  • Admin
  • Aldous Project
  • Arboga Elektronikhistoriska Förening
  • Bebino
  • Cyberphoto
  • Flickr
  • Fordonsradio
  • Google Calendar
  • Google Reader
  • Jan Jörnmark
  • Janne Hägerholm Foto
  • Kaffebrus
  • Laszlo Incze
  • Ninite
  • Photax
  • Picasa from Google
  • RAW-Shooter Essentials
  • Slashdot
  • SLR Gear (Lens reviews)
  • Svenska Dagbladed

Shortcuts

  • Latest Flickr Activity
  • My 500 latest shots
  • My 500 most interesting

Archive

Etiketter

  • 5 km
  • 365
  • Android
  • c25k
  • camera
  • condition
  • couch to 5 km running
  • Excursion
  • exercise
  • Google
  • gps
  • internet
  • jogging
  • light
  • linux
  • logging
  • löpning
  • Macro
  • motion
  • music
  • Nature
  • nikon
  • outdoors
  • Photography
  • photo walk
  • resting
  • running
  • shape
  • sick
  • SL
  • Software
  • springa
  • starting
  • stockholm
  • street
  • Studio
  • summer
  • Sverige
  • sweden
  • Technical
  • training
  • Travel
  • water
  • winter
  • workout
Drivs med WordPress