mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-01-11 14:20:23 +01:00
Question about the SSH key authorization mechanism #62
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @wicsp on GitHub (Oct 28, 2025).
I wonder how can I ssh to a machine with a normal user?
In
vars/default.nix, it set the keys from the users in different hosts asmainSshAuthorizedKeys, and set the super keyromanticassecondaryAuthorizedKeysas follow:In
modules/base/users.nix, it just allow themainSshAuthorizedKeysfor ssh.But in
home/base/tui/ssh.nix, it set/etc/agenix/ssh-key-romanticas the default identityFile for all the hosts in the local network.When I try to ssh to a host in local network with a normal user (
ryanin this repo), it automatically select the/etc/agenix/ssh-key-romantic, and openssh will refuse to connect because it just acceptmainSshAuthorizedKeys.Did I misunderstand?
@ryan4yin commented on GitHub (Nov 4, 2025):
The behaviour you see is exactly what the config is designed to do:
Only the keys listed in
mainSshAuthorizedKeysare accepted for the normal user (ryan).The
secondaryAuthorizedKeys(a.k.a. the “romantic” key) is not in that list, so the server rightfully rejects it.The
rootaccount, on the other hand, does get both key sets(modules/nixos/base/user-group.nix):so the romantic key works only when you log in as
root.The host aliases defined in
vars/networking.nixdon’t specify anidentityFile, so the client is free to use any keys in ssh-agent when login via host aliases.In short: the romantic key is intentionally restricted to
root, not for daily use.