Skip to content

Commit

Permalink
[nixos/server] disable passwordless sudo and enable ssh-key authentic…
Browse files Browse the repository at this point in the history
…ation

Be aware to set `ForwardAgent yes` in the client ssh config.
  • Loading branch information
pSub committed Mar 16, 2024
1 parent 3b1aad8 commit 34299c9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions nixos/server/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@

# Deploy without root
nix.settings.trusted-users = [ "root" "deployer" ];
security.sudo.wheelNeedsPassword = false;
security.sudo.enable = true;

# TODO: Separate keys for root and deployer
users.users.root.openssh.authorizedKeys.keys = config.users.users.deployer.openssh.authorizedKeys.keys;

security.sudo.execWheelOnly = true;
security.loginDefs.settings = {
Expand Down Expand Up @@ -272,6 +275,8 @@
time.timeZone = "Europe/Berlin";

# Security - PAM
security.pam.enableSSHAgentAuth = true;
security.pam.services.sudo.sshAgentAuth = true;
security.pam.loginLimits = [
{
domain = "*";
Expand Down Expand Up @@ -459,7 +464,7 @@
MaxAuthTries = 3;
ClientAliveCountMax = 2;
AllowTcpForwarding = "no";
AllowAgentForwarding = "no";
AllowAgentForwarding = "yes";
AllowStreamLocalForwarding = "no";
AuthenticationMethods = "publickey";
TCPKeepAlive = "no";
Expand Down

0 comments on commit 34299c9

Please sign in to comment.