GithubHelp home page GithubHelp logo

pam.alert's Introduction

Introduction

A utility for mailgun's API to send emails regarding the SSH successful login

How does it work?

Linux-PAM short for Pluggable Authentication Module is the core of user's dynamic authentication support for applications and services in a Linux system.

tl;dr PAM handles authentication for multiple services on Linux OS.

This utility requires mailgun's API to allow scripting in use of their SMTP. Therefore, when attempting to connect your server via SSH, it will process /etc/pam.d/sshd in regards to the shell script's location pam_alert.sh.

Installation

Be aware! The following steps were tested with Ubuntu 18.04

  1. You will be required to sign up to mailgun's website to acquire the API.
  2. Install pam.alert
git clone https://github.com/JustRLC/pam.alert
  1. Move directory to /etc/pam.alert
sudo mv pam.alert /etc/pam.alert; sudo chmod 0755 /etc/pam.alert; cd /etc/pam.alert
  1. For security purposes, allow only the root user to have full privileges over the file.
sudo chmod 0700 pam_alert.sh
sudo chown root:root pam_alert.sh
  1. Edit pam_alert.sh using a tool you desire (via nano or Vim) and add your Mailgun's API and DOMAIN, and TO (your email) e.g. gmail account. Then, save the file.
API='' #Your Mailgun API
DOMAIN='' #Domain provided by Mailgun
TO='' #The email you want to send the alerts
  1. Locate to /etc/pam.d/ and edit sshd within the directory. Add the following line and save it:
# SSH Alert script
session optional pam_exec.so /etc/pam.alert/pam_alert.sh
  1. Ta-dah! Now, you can exit the server and login again.

Note

For testing purposes, the module is included as optional, so that you can still log in if the execution fails. After you made sure that it works, you can change optional to required. Then login won't be possible unless the execution of your hook script is successful (Not essential, but I would recommend doing so.).

pam.alert's People

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.