mirror of
https://github.com/kittywitch/nixfiles.git
synced 2026-02-09 04:19:19 -08:00
Some checks failed
nodes / nodes check (push) Has been cancelled
nodes / nodes-home-home-base (push) Has been cancelled
nodes / nodes-home-home-graphical (push) Has been cancelled
nodes / nodes-home-home-neovim (push) Has been cancelled
nodes / nodes-home-home-shell (push) Has been cancelled
nodes / nodes-nixos-mai (push) Has been cancelled
nodes / nodes-nixos-mei (push) Has been cancelled
30 lines
780 B
Nix
30 lines
780 B
Nix
{
|
|
pkgs,
|
|
lib,
|
|
config,
|
|
...
|
|
}: let
|
|
inherit (lib.modules) mkAfter mkDefault;
|
|
in {
|
|
sops.secrets.ssh-notify = {
|
|
sopsFile = ./secrets.yaml;
|
|
};
|
|
security.pam.services.sshd.text = let
|
|
notify = pkgs.writeShellScript "notify" ''
|
|
set -o allexport
|
|
source ${config.sops.secrets.ssh-notify.path}
|
|
set +o allexport
|
|
if [ "''${PAM_TYPE}" = "open_session" ]; then
|
|
curl -s -X POST \
|
|
-H "Authorization: Bearer ''${SSH_NOTIFY_TOKEN}" \
|
|
-H prio:high \
|
|
-H tags:warning \
|
|
-d "SSH login to ${config.networking.hostName}: ''${PAM_USER} from ''${PAM_RHOST}" \
|
|
https://ntfy.kittywit.ch/alerts
|
|
fi
|
|
'';
|
|
in
|
|
mkDefault (mkAfter ''
|
|
session optional pam_exec.so seteuid ${notify}
|
|
'');
|
|
}
|