Simple Guard Server is a security script designed to monitor SSH connections to a VPS and send notifications to a Discord channel when a new connection is established. The script also restricts SSH access during specific hours.
- Discord Notifications: Sends a message to a specified Discord channel when a new SSH connection is made.
- IP Logging: Logs the IP address of the user and the VPS.
- Time-based SSH Access: Automatically restricts SSH access during non-working hours (00:00 - 08:00 according to the Europe/Moscow time zone).
- VPS: You need a VPS with SSH access.
- Discord Webhook: Create a webhook in your Discord server and note the URL.
- Role ID: Note the role ID of the role you want to mention.
-
Clone the Repository
git clone https://github.com/yume-real/simple-guard-server/ cd Simple-Guard-Server
-
Configure the Script
Edit the script
simple-guard-server.sh
and replaceYOUR_WEBHOOK_URL
andYOUR_ROLE_ID
with your actual Discord webhook URL and role ID:discord_webhook_url="YOUR_WEBHOOK_URL" role_id="YOUR_ROLE_ID"
-
Ensure Required Tools are Installed
Make sure
ufw
,jq
, andcurl
are installed:sudo apt-get update sudo apt-get install ufw jq curl
-
Set Script Permissions
Grant execution permissions to the script:
chmod +x connects_monitor.sh
-
Run the Script
Execute the script to start monitoring SSH connections:
./connects_monitor.sh
To run the script as a service and ensure it starts on boot, you can create a systemd service unit:
-
Create Service Unit File
sudo nano /etc/systemd/system/connects_monitor.service
-
Add the Following Content
[Unit] Description=Simple Guard Server [Service] ExecStart=/path/to/your/connects_monitor.sh Restart=always User=root [Install] WantedBy=multi-user.target
Make sure to replace
/path/to/your/connects_monitor.sh
with the actual path to your script. -
Enable and Start the Service
sudo systemctl daemon-reload sudo systemctl enable connects_monitor sudo systemctl start connects_monitor
-
Check Service Status
Verify that the service is running with:
sudo systemctl status connects_monitor
The script continuously monitors SSH connections. When a new connection is detected, it sends a message to the specified Discord channel with the connection details, including the time, username, user's IP address, and the VPS IP address. The script also adjusts SSH access permissions according to the specified time rules.
Feel free to submit issues or pull requests to enhance the functionality or fix bugs.
MIT License
Enjoy secure and monitored SSH access with Simple Guard Server!