dotfiles/server-quickstart.md
2026-02-27 23:18:57 +01:00

50 lines
1.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# NixOS server quick-start
Hostname, user, SSH, key-based login.
## 0. Installer choice
No Ethernet? Use the **graphical** ISO (`nixos-graphical-*-x86_64-linux.iso`). It has NetworkManager and a desktop—join WiFi in the GUI, then use a terminal. The minimal ISO has no GUI and WiFi on the live system is fiddly.
## 1. Prerequisites
NixOS installed, machine on the network, console or SSH.
## 2. Hostname
```nix
networking.hostName = "myserver";
```
## 3. User
```nix
users.users.danny = {
isNormalUser = true;
extraGroups = [ "wheel" "networkmanager" ];
# hashedPassword = "..."; # or omit for key-only
};
```
## 4. SSH
```nix
services.openssh.enable = true;
users.users.danny.openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAA... your-key-comment"
];
```
To avoid committing keys (e.g. public repo): omit `openssh.authorizedKeys` and push keys via `scp ~/.ssh/*.pub danny@server:/tmp/` then on server: `cat /tmp/*.pub >> ~/.ssh/authorized_keys`.
Optional: `services.openssh.settings = { PasswordAuthentication = false; PermitRootLogin = "no"; };`
## 5. Apply and test
```bash
sudo nixos-rebuild switch
# or: sudo nixos-rebuild switch --flake /path/to/dotfiles/nixos#hostname
```
Then from your main machine: `ssh danny@myserver`