Difference between revisions of "SSH"
From NixOS Wiki
Chloedgreene (talk | contribs) (Added a Recommendation/Warning to use Fail2ban as a base level of security) |
m (Added tip to include SSHD without autostarting it while keeping the systemd service available) |
||
Line 36: | Line 36: | ||
The complete list of options [https://search.nixos.org/options?show=services.openssh can be found here]. | The complete list of options [https://search.nixos.org/options?show=services.openssh can be found here]. | ||
+ | |||
+ | === Tips === | ||
+ | |||
+ | To include SSH server without autostarting it, its required to override the systemd service like so | ||
+ | <syntaxhighlight lang="nix"> | ||
+ | systemd.services.sshd.wantedBy = lib.mkForce [ ]; | ||
+ | </syntaxhighlight> |
Revision as of 09:53, 24 April 2025
SSH (Secure Shell) is a protocol for securely accessing and managing a remote computer over an insecure network.
Configuration
In your /etc/nix/configuration.nix
add services.openssh.
Only the enable
option is required.
services.openssh = {
enable = true;
ports = [ 22 ];
settings = {
PasswordAuthentication = true;
AllowUsers = null; # Allows all users by default. Can be [ "user1" "user2" ]
UseDns = true;
X11Forwarding = false;
PermitRootLogin = "prohibit-password"; # "yes", "without-password", "prohibit-password", "forced-commands-only", "no"
};
};
You may have to open a port in the firewall:
networking.firewall.allowedTCPPorts
The complete list of options can be found here.
Tips
To include SSH server without autostarting it, its required to override the systemd service like so
systemd.services.sshd.wantedBy = lib.mkForce [ ];