diff options
Diffstat (limited to 'modules/services')
| -rw-r--r-- | modules/services/git.nix | 5 | ||||
| -rw-r--r-- | modules/services/nextcloud.nix | 11 | ||||
| -rw-r--r-- | modules/services/openssh.nix | 96 |
3 files changed, 60 insertions, 52 deletions
diff --git a/modules/services/git.nix b/modules/services/git.nix index 12ef804..a9f8213 100644 --- a/modules/services/git.nix +++ b/modules/services/git.nix @@ -82,7 +82,10 @@ config.sops.secrets."borgbase_ssh_key".path } -o StrictHostKeyChecking=accept-new"; }; - extraCreateArgs = [ "--info" "--stats" ]; + extraCreateArgs = [ + "--info" + "--stats" + ]; compression = "auto,lzma"; startAt = "daily"; preHook = '' diff --git a/modules/services/nextcloud.nix b/modules/services/nextcloud.nix index 38b6145..43f801a 100644 --- a/modules/services/nextcloud.nix +++ b/modules/services/nextcloud.nix @@ -85,7 +85,10 @@ } -o StrictHostKeyChecking=accept-new"; TMPDIR = "/var/tmp"; }; - extraCreateArgs = [ "--info" "--stats" ]; + extraCreateArgs = [ + "--info" + "--stats" + ]; compression = "auto,lzma"; startAt = "daily"; readWritePaths = [ @@ -95,7 +98,7 @@ preHook = '' set -euo pipefail export BORG_REPO="$(cat ${config.sops.secrets."borg_nextcloud_repo".path})" - + INSTALL="${pkgs.coreutils}/bin/install" FIND="${pkgs.findutils}/bin/find" MYSQLDUMP="${pkgs.mariadb.client}/bin/mariadb-dump" @@ -122,7 +125,9 @@ ''; }; - systemd.services."borgbackup-job-nextcloud".unitConfig.OnFailure = [ "notify-backup-failure@%n.service" ]; + systemd.services."borgbackup-job-nextcloud".unitConfig.OnFailure = [ + "notify-backup-failure@%n.service" + ]; services.fail2ban = { enable = true; diff --git a/modules/services/openssh.nix b/modules/services/openssh.nix index 98241df..5775ca8 100644 --- a/modules/services/openssh.nix +++ b/modules/services/openssh.nix @@ -38,55 +38,55 @@ security.pam.services.sshd.text = lib.mkDefault ( lib.mkAfter '' session optional pam_exec.so ${pkgs.writeShellScript "ssh-login-notify" '' - if [ "$PAM_TYPE" = "open_session" ]; then - TIMESTAMP=$(${pkgs.coreutils}/bin/date "+%Y-%m-%d %H:%M:%S %Z") - HOSTNAME=$(${pkgs.coreutils}/bin/cat /etc/hostname) - - ( - ${pkgs.coreutils}/bin/echo "To: leander@schererleander.de" - ${pkgs.coreutils}/bin/echo "From: root@sachiel.schererleander.de" - ${pkgs.coreutils}/bin/echo "Subject: SSH Login Alert: $PAM_USER" - ${pkgs.coreutils}/bin/echo "Content-Type: text/html; charset=UTF-8" - ${pkgs.coreutils}/bin/echo "" - ${pkgs.coreutils}/bin/cat <<EOF - <!DOCTYPE html> - <html> - <head> - <meta name="color-scheme" content="light dark"> - <style> - :root { color-scheme: light dark; } - body { font-family: sans-serif; line-height: 1.5; color: #000; background: #fff; max-width: 800px; margin: 0 auto; padding: 20px; } - h1 { border-bottom: 2px solid #000; color: #d97706; } - table { width: 100%; border-collapse: collapse; margin-bottom: 15px; font-size: 13px; } - th, td { text-align: left; padding: 6px; border-bottom: 1px solid #ddd; } - a { color: #0066cc; } - @media (prefers-color-scheme: dark) { - body { background: #121212; color: #eee; } - h1, th { border-color: #555; } - h1 { color: #f59e0b; } - th, td { border-color: #333; } - a { color: #66b3ff; } - } - </style> - </head> - <body> - <h1>SSH Login Alert</h1> - - <p>A successful SSH login was just detected.</p> + if [ "$PAM_TYPE" = "open_session" ]; then + TIMESTAMP=$(${pkgs.coreutils}/bin/date "+%Y-%m-%d %H:%M:%S %Z") + HOSTNAME=$(${pkgs.coreutils}/bin/cat /etc/hostname) + + ( + ${pkgs.coreutils}/bin/echo "To: leander@schererleander.de" + ${pkgs.coreutils}/bin/echo "From: root@sachiel.schererleander.de" + ${pkgs.coreutils}/bin/echo "Subject: SSH Login Alert: $PAM_USER" + ${pkgs.coreutils}/bin/echo "Content-Type: text/html; charset=UTF-8" + ${pkgs.coreutils}/bin/echo "" + ${pkgs.coreutils}/bin/cat <<EOF + <!DOCTYPE html> + <html> + <head> + <meta name="color-scheme" content="light dark"> + <style> + :root { color-scheme: light dark; } + body { font-family: sans-serif; line-height: 1.5; color: #000; background: #fff; max-width: 800px; margin: 0 auto; padding: 20px; } + h1 { border-bottom: 2px solid #000; color: #d97706; } + table { width: 100%; border-collapse: collapse; margin-bottom: 15px; font-size: 13px; } + th, td { text-align: left; padding: 6px; border-bottom: 1px solid #ddd; } + a { color: #0066cc; } + @media (prefers-color-scheme: dark) { + body { background: #121212; color: #eee; } + h1, th { border-color: #555; } + h1 { color: #f59e0b; } + th, td { border-color: #333; } + a { color: #66b3ff; } + } + </style> + </head> + <body> + <h1>SSH Login Alert</h1> + + <p>A successful SSH login was just detected.</p> - <table> - <tr><th>User</th><td>$PAM_USER</td></tr> - <tr><th>Host</th><td>$HOSTNAME</td></tr> - <tr><th>Time</th><td>$TIMESTAMP</td></tr> - <tr><th>IP Address</th><td><a href="https://iplookup.flagfox.net/?ip=$PAM_RHOST">$PAM_RHOST</a></td></tr> - <tr><th>Service</th><td>$PAM_SERVICE</td></tr> - <tr><th>TTY</th><td>$PAM_TTY</td></tr> - </table> - </body> - </html> -EOF - ) | /run/wrappers/bin/sendmail -f root@sachiel.schererleander.de leander@schererleander.de - fi + <table> + <tr><th>User</th><td>$PAM_USER</td></tr> + <tr><th>Host</th><td>$HOSTNAME</td></tr> + <tr><th>Time</th><td>$TIMESTAMP</td></tr> + <tr><th>IP Address</th><td><a href="https://iplookup.flagfox.net/?ip=$PAM_RHOST">$PAM_RHOST</a></td></tr> + <tr><th>Service</th><td>$PAM_SERVICE</td></tr> + <tr><th>TTY</th><td>$PAM_TTY</td></tr> + </table> + </body> + </html> + EOF + ) | /run/wrappers/bin/sendmail -f root@sachiel.schererleander.de leander@schererleander.de + fi ''} '' ); |
