SSH public key authentication: Difference between revisions

Phobos (talk | contribs)
m Minor edit for consistency in commands
m Make keyFiles suggestion compatible with pure evaluation mode
Tags: Mobile edit Mobile web edit Visual edit
 
(2 intermediate revisions by one other user not shown)
Line 54: Line 54:
<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
$ ssh-add ~/.ssh/id_rsa
$ ssh-add ~/.ssh/id_rsa
Enter passphrase for .ssh/id_rsa:  
Enter passphrase for /home/user/.ssh/id_rsa:  
Identity added: .ssh/id_rsa (myaccounts@mymachine)
Identity added: /home/user/.ssh/id_rsa (myaccounts@mymachine)
</syntaxhighlight>
</syntaxhighlight>


Line 62: Line 62:
== SSH server configuration ==
== SSH server configuration ==


You can manage SSH authorized public keys declaratively by adding them to your system to your system configuration:
You can manage SSH authorized public keys declaratively by adding them to your system configuration:


{{file|/etc/nixos/configuration.nix|nix|
{{file|/etc/nixos/configuration.nix|nix|
Line 76: Line 76:
Alternatively, you can reference a custom file containing the authorized keys:
Alternatively, you can reference a custom file containing the authorized keys:


{{file|/etc/nixos/configuration.nix|nix|
{{file|||
<nowiki>
<nowiki>
   users.users."user".openssh.authorizedKeys.keyFiles = [
   users.users."user".openssh.authorizedKeys.keyFiles = [
     /etc/nixos/ssh/authorized_keys
     ./ssh/authorized_keys
   ];
   ];
</nowiki>
</nowiki>
}}
|name=/etc/nixos/configuration.nix|lang=nix}}


For additional configuration options, see the {{nixos:option|users.users.*.openssh}} module documentation.
For additional configuration options, see the {{nixos:option|users.users.*.openssh}} module documentation.