summary refs log tree commit diff stats
path: root/modules/ssh.nix
blob: 30a79adaacbd3e30e51d17649408d95336c1d725 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{ config, libs, pkgs, ... }:
{

  environment.systemPackages = [ pkgs.openssh ];

  services.openssh = {
    enable = true;
    settings.PasswordAuthentication = false;
  };

  networking.firewall.allowedTCPPorts = [ 22 ];

  services.monit.config = ''
    check process sshd with pidfile /var/run/sshd.pid
    start program  "${pkgs.systemd}/bin/systemctl start sshd"
    stop program  "${pkgs.systemd}/bin/systemctl stop sshd"
    if failed port 22 protocol ssh for 2 cycles then restart
  '';
}