Giter VIP home page Giter VIP logo

discord-ssh-logging's Introduction

SSH Logging to Discord

This script enhances the functionality of Alexander Henderson's original script for logging SSH sessions to Discord. The original script and blog post can be found here, and credit goes to Alexander Henderson (alexandzors).

Overview

This Bash script is designed to be added to /sbin/ and made executable. It integrates with the SSH PAM (Pluggable Authentication Modules) to log SSH session events, such as login and logout, to a Discord channel through a webhook.

Preview

Preview GIF

Installation

  1. Copy the Script:

    • Copy the script to /sbin/ and make it executable:
      sudo touch /sbin/sshd-login
      sudo chmod +x /sbin/sshd-discord-login.shsudo chmod +x /sbin/sshd-login
      sudo chown root:root /sbin/sshd-login
      sudo nano /sbin/sshd-login
  2. Edit PAM Configuration:

    • Open /etc/pam.d/sshd in a text editor.
    • Add the following line to the bottom of the file:
      session optional pam_exec.so /sbin/sshd-discord-login.sh
      
  3. Set Permissions for Logging:

    • Ensure the log file has the correct permissions:
      sudo touch /var/log/seen_ips.log
      sudo chmod +x /var/log/seen_ips.log
      sudo chown root:root /var/log/seen_ips.log
  4. Set Configuration Variables:

    • Edit the script and set the WEBHOOK_URL, DISCORDUSER, and URGENT_ROLE variables to appropriate values.
  5. Restart SSH Service:

    • Restart the SSH service for changes to take effect:
      sudo service sshd restart

Usage

Once installed, the script will send messages to the configured Discord channel when users log in or out via SSH. It differentiates between new and known remote hosts, providing additional context.

Credits

Disclaimer

This script is provided as-is without any warranty. Use it at your own risk, and ensure that you comply with your organization's policies and guidelines.

discord-ssh-logging's People

Contributors

trixzyy avatar

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.