Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/sshd: change authorizedKeysFiles #94434

Closed
wants to merge 1 commit into from

Conversation

Izorkin
Copy link
Contributor

@Izorkin Izorkin commented Aug 1, 2020

Motivation for this change

This update need to correct work this configuration:

default/services/sshd.nix

{ lib, ... }:
{
  services.openssh = with lib; {
...
    authorizedKeysFiles = [
      "/etc/ssh/authorized_keys.d/%u"
    ];
...

servers/vm-test/services/sshd.nix

    services.openssh = {
      authorizedKeysFiles = [ /var/lib/gitea/.ssh/authorized_keys" ];
    };

Result before update:

AuthorizedKeysFile /etc/ssh/authorized_keys.d/%u .ssh/authorized_keys .ssh/authorized_keys2 /etc/ssh/authorized_keys.d/%u /var/data/gitea/.ssh/authorized_keys

Result after update:

AuthorizedKeysFile /etc/ssh/authorized_keys.d/%u /var/data/gitea/.ssh/authorized_keys

cc @Ma27 @aanderse @fpletz

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@aanderse
Copy link
Member

aanderse commented Aug 1, 2020

The idea behind the current code is to merge by default and have the user specify mkForce if they want to override. I think the current behavior is ideal.

@Izorkin
Copy link
Contributor Author

Izorkin commented Aug 1, 2020

If use in default/services/sshd.nix mkForce configuration not working. Result only

AuthorizedKeysFile /etc/ssh/authorized_keys.d/%u

Copy link
Member

@Ma27 Ma27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If use in default/services/sshd.nix mkForce configuration not working. Result only

You should use mkForce for your values if needed. This is exactly what this was designed for.

@@ -232,9 +232,12 @@ in
'';
};

# These values are merged with the ones defined externally, see:
# https://github.com/NixOS/nixpkgs/pull/10155
# https://github.com/NixOS/nixpkgs/pull/41745
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No they aren't! If those are option-defaults, those will be lost when defining authorizedKeysFiles.

@aanderse
Copy link
Member

aanderse commented Aug 1, 2020

@Izorkin you should set like this:

services.openssh.authorizedKeysFile = lib.mkForce [ "/etc/ssh/authorized_keys.d/%u" "/var/data/gitea/.ssh/authorized_keys" ];

@Izorkin
Copy link
Contributor Author

Izorkin commented Aug 9, 2020

Worked with this variant:
default/services/sshd.nix

{ lib, ... }:
{
  services.openssh = with lib; {
...
    authorizedKeysFiles = mkForce [
      "/etc/ssh/authorized_keys.d/%u"
    ];
...

servers/vm-test/services/sshd.nix

    services.openssh = with lib; mkForce {
      authorizedKeysFiles = [ /var/lib/gitea/.ssh/authorized_keys" ];
    };

@Izorkin Izorkin closed this Aug 9, 2020
@Izorkin Izorkin deleted the sshd-authkeys branch August 9, 2020 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants