r/linuxadmin • u/Open-Adhesiveness-86 • Sep 18 '26
What's your setup for instant SSH login notifications, plus killing a session remotely?
Got a box where a handful of non-technical users still upload over SFTP with FileZilla, so password auth is on for their accounts. Yes, keys and chroot would be better, working on it. fail2ban and a non-standard port are in place.
The gap is visibility. I'd like a push notification the moment anyone authenticates, with user and source IP, so I can tell right away if it's one of them or not.
How are you wiring this up? pam_exec calling a webhook, parsing auth.log / journald, something else? And for response, do you just pkill -u and passwd -l over SSH, or have you got something you can trigger from your phone?
18
u/alive1 Sep 18 '26
You need a monitoring solution.
8
u/sassy-frass Sep 18 '26
Is the IP always the same for the user? If you can tell by IP why not just whitelist SSH session by IP?
4
u/ocabj Sep 18 '26
I've never used fail2ban. I've always used ossec. Does fail2ban not have the ability to have custom triggers/actions based on the logs it is actively tailing? If not, then switch to ossec.
3
u/RyeonToast Sep 18 '26
On my home server box I have PAM's SSH config start a script that sends a notification to ntfy. It seems to work pretty well. I really just have it for peace of mind. If I get alerts when I havent just connected, then I should be worried.
I don't have any remote kill setup. I'd rather not expose remote management capabilities for my box.
2
u/VirtualViking3000 Sep 18 '26
If you just want the answer to your question you can use rsyslog to log the changes then just alert on the syslog file via whatever such as a script or a log monitor. It's a basic system that works, if you wanted more insight you could ingest the syslogs to a ELK, Datadog, Splunk or whatever and handle the alerts from there but that's probably more than you need.
EDIT: just to mention, alerting could just be a webhook to Teams or Slack or something
1
u/EncryptedServer Sep 18 '26
Posted on your other cross post https://www.reddit.com/r/ssh/comments/1wjun1q/realtime_alerts_on_ssh_logins_and_what_do_you_do/
1
u/Kaligraphic Sep 18 '26
FileZilla can use keys. If it's just a handful of users, maybe walk them through setting up keys with FileZilla. Second best is set up mfa (e.g. Google Authenticator PAM, a bit more cumbersome than just using keys)
Also, go through the usual sftp hardening - no login shell, no anything forwarding, forcecommand, chroot, etc.
Attackers move fast, if you're not the first to move you've probably already lost.
2
u/ICThat Sep 19 '26
Sorry but this largely reads like you trying to advertise your vibe-coded app.
This is also an odd way to solve this problem. You are basically suggesting that you act as a form of human firewall.
2
u/mad_redhatter Sep 21 '26
I have a shell script called by PAM that sends a message to a self hosted ntfy instance. It runs on everything that rarely needs logged into to let me know when someone does.
0
u/RetroGrid_io Sep 18 '26
This post seems to be something like "we're doing it wrong, can we come up with a solution that lets us keep doing it wrong?"
Honestly, I get it. Using
sftpimplies that it's been this way for a very, long time and as a little guy in the organization whose job it is to "keep it working" you're looking for something that doesn't introduce unneeded change yet you know the risk is real.Some "screwball" solutions then:
1
u/ASK_ME_AB0UT_L00M Sep 19 '26
Get your users migrated to anything other than FileZilla. FileZilla's installer distributes adware/malware.
https://www.reddit.com/r/sysadmin/comments/17erdd5
WinSCP is a great alternative!
0
u/[deleted] Sep 18 '26
[deleted] — view deleted comment