Skip to content

Commit e2bc95f

Browse files
committed
BUILD: Add sudo password to catcolab account
1 parent d0751ab commit e2bc95f

6 files changed

Lines changed: 31 additions & 8 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ jobs:
503503
504504
- name: Deploy to catcolab-next
505505
run: |
506-
nix run github:serokell/deploy-rs -- --skip-checks .#catcolab-next
506+
nix run github:serokell/deploy-rs -- --skip-checks .#catcolab-next-ci
507507
508508
- name: Verify deployment
509509
run: |

flake.nix

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@
330330
profiles.system = {
331331
sshUser = "catcolab";
332332
user = "root";
333+
interactiveSudo = true;
333334
path = deploy-rs.lib.${linuxSystem}.activate.nixos self.nixosConfigurations.catcolab;
334335
};
335336
};
@@ -338,6 +339,14 @@
338339
profiles.system = {
339340
sshUser = "catcolab";
340341
user = "root";
342+
interactiveSudo = true;
343+
path = deploy-rs.lib.${linuxSystem}.activate.nixos self.nixosConfigurations.catcolab-next;
344+
};
345+
};
346+
catcolab-next-ci = {
347+
hostname = "backend-next.catcolab.org";
348+
profiles.system = {
349+
sshUser = "root";
341350
path = deploy-rs.lib.${linuxSystem}.activate.nixos self.nixosConfigurations.catcolab-next;
342351
};
343352
};
@@ -349,9 +358,8 @@
349358
"-p"
350359
"2221"
351360
];
352-
sshUser = "catcolab";
361+
sshUser = "root";
353362
path = deploy-rs.lib.${linuxSystem}.activate.nixos self.nixosConfigurations.catcolab-vm;
354-
user = "root";
355363
};
356364
};
357365
};

infrastructure/hosts/catcolab-next/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ in
4848
catcolab-next-deployuser
4949
kasbah
5050
];
51+
sudoPasswordHash = "$y$j9T$Gvhb3z8dNG2Gzk5STLY2q0$w8hilnb9bC2aNuH8Vx4FpgRzotKpFJeF2oFQ24MGMK8";
5152
backup = {
5253
enable = true;
5354
rcloneConfigFile = config.age.secrets.rcloneConf.path;

infrastructure/hosts/catcolab-vm/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
environmentFile = /etc/catcolab/catcolab-secrets.env;
3131
host = {
3232
enable = true;
33+
sudoPasswordHash = "$y$j9T$Gvhb3z8dNG2Gzk5STLY2q0$w8hilnb9bC2aNuH8Vx4FpgRzotKpFJeF2oFQ24MGMK8";
3334
userKeys = [
3435
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMiaHaeJ5PQL0mka/lY1yGXIs/bDK85uY1O3mLySnwHd j@jmoggr.com"
3536
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIM1K/FB6dCjo1/xfddi9VoHEGchFo/bcz6v7SC7wAuFQ kaspar@topos"

infrastructure/hosts/catcolab/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ in
4343
jmoggr
4444
kasbah
4545
];
46+
sudoPasswordHash = "$y$j9T$Gvhb3z8dNG2Gzk5STLY2q0$w8hilnb9bC2aNuH8Vx4FpgRzotKpFJeF2oFQ24MGMK8";
4647
backup = {
4748
enable = true;
4849
rcloneConfigFile = config.age.secrets.rcloneConf.path;

infrastructure/modules/catcolab/host.nix

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ with lib;
1717
description = "SSH public keys to access the catcolab user.";
1818
default = [ ];
1919
};
20+
sudoPasswordHash = mkOption {
21+
type = types.str;
22+
description = "Hashed password for sudo authentication. Generate with: mkpasswd";
23+
};
24+
rootKeys = mkOption {
25+
type = types.listOf types.str;
26+
description = "SSH public keys for root access only (e.g., for CI deployment).";
27+
default = [ ];
28+
};
2029
};
2130

2231
config = lib.mkIf config.catcolab.host.enable {
@@ -26,20 +35,23 @@ with lib;
2635
isNormalUser = true;
2736
extraGroups = [ "wheel" ];
2837
openssh.authorizedKeys.keys = config.catcolab.host.userKeys;
38+
hashedPassword = config.catcolab.host.sudoPasswordHash;
2939
};
30-
# TODO: root access can be dropped after the next prod deploy
31-
root.openssh.authorizedKeys.keys = config.catcolab.host.userKeys;
40+
41+
# Need to access root for deploying to bypass sudo password. The root user should not generally
42+
# not be used directly.
43+
root.openssh.authorizedKeys.keys = config.catcolab.host.userKeys ++ config.catcolab.host.rootKeys;
3244
};
3345

3446
groups.catcolab = { };
3547
mutableUsers = false;
3648
};
3749

38-
security.sudo = {
39-
wheelNeedsPassword = false;
50+
services.openssh = {
51+
enable = true;
52+
settings.PasswordAuthentication = false;
4053
};
4154

42-
services.openssh.enable = true;
4355
nix = {
4456
settings.trusted-users = [
4557
"catcolab"

0 commit comments

Comments
 (0)