Fix ssh permissions (take 3)
This commit is contained in:
parent
e3147858c3
commit
b6118974ec
|
@ -1,15 +1,5 @@
|
|||
{ config, ... }:
|
||||
{
|
||||
programs.ssh.enable = true;
|
||||
|
||||
satellite.persistence.at.state.apps.ssh.directories = [ ".ssh" ];
|
||||
systemd.user.tmpfiles.rules =
|
||||
let
|
||||
ssh = "${config.satellite.persistence.at.state.home}/ssh/.ssh";
|
||||
in
|
||||
[
|
||||
"d ${ssh} 0755 ${config.home.username} users"
|
||||
"e ${ssh}/id_rsa 0700 ${config.home.username} users"
|
||||
"e ${ssh}/id_ed25519 0700 ${config.home.username} users"
|
||||
];
|
||||
}
|
||||
|
|
|
@ -6,17 +6,22 @@
|
|||
...
|
||||
}:
|
||||
{
|
||||
# This is it's own attribute in order to prevent infinite recursion
|
||||
# in certain places.
|
||||
satellite.pilot.name = lib.mkDefault "adrielus";
|
||||
|
||||
# {{{ Password handling
|
||||
sops.secrets.pilot_password = {
|
||||
sopsFile = ../secrets.yaml;
|
||||
neededForUsers = true;
|
||||
};
|
||||
# }}}
|
||||
|
||||
users = {
|
||||
# Configure users through nix only
|
||||
mutableUsers = false;
|
||||
|
||||
# {{{ Create pilot user
|
||||
users.pilot = {
|
||||
inherit (config.satellite.pilot) name;
|
||||
|
||||
|
@ -44,5 +49,21 @@
|
|||
|
||||
openssh.authorizedKeys.keyFiles = (import ./common.nix).authorizedKeys { inherit outputs lib; };
|
||||
};
|
||||
# }}}
|
||||
};
|
||||
|
||||
# {{{ Set user-specific ssh permissions
|
||||
# This is mainly useful because home-manager can often fail if the perms on
|
||||
# `~/.ssh` are incorrect.
|
||||
systemd.tmpfiles.rules =
|
||||
let
|
||||
user = config.users.users.pilot;
|
||||
ssh = "/persist/state/${user.home}/ssh/.ssh";
|
||||
in
|
||||
[
|
||||
"d ${ssh} 0755 ${user.name} ${user.group}"
|
||||
"e ${ssh}/id_rsa 0700 ${user.name} ${user.group}"
|
||||
"e ${ssh}/id_ed25519 0700 ${user.name} ${user.group}"
|
||||
];
|
||||
# }}}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue