server-quickstart: make guide more concise
Made-with: Cursor
This commit is contained in:
parent
503ef7051a
commit
4ffa774d3d
1 changed files with 7 additions and 37 deletions
|
|
@ -1,78 +1,48 @@
|
|||
# NixOS server quick-start
|
||||
|
||||
Get a new NixOS machine online as a server: hostname, user, SSH, and key-based login.
|
||||
Hostname, user, SSH, key-based login.
|
||||
|
||||
## 0. Installer choice
|
||||
|
||||
You can't always assume the machine has an Ethernet port (e.g. some laptops, thin clients). The **minimal** ISO has no GUI and Wi‑Fi on the live system is fiddly (wpa_supplicant, dhcpcd, no NetworkManager). For machines without Ethernet, prefer the **graphical** NixOS installer: it includes NetworkManager and a desktop, so you can join Wi‑Fi in the GUI, then open a terminal and follow the same config steps below. Download the graphical ISO from the same NixOS channel (e.g. `nixos-graphical-*-x86_64-linux.iso` instead of `nixos-minimal-*`).
|
||||
No Ethernet? Use the **graphical** ISO (`nixos-graphical-*-x86_64-linux.iso`). It has NetworkManager and a desktop—join Wi‑Fi in the GUI, then use a terminal. The minimal ISO has no GUI and Wi‑Fi on the live system is fiddly.
|
||||
|
||||
## 1. Prerequisites
|
||||
|
||||
- NixOS installed (minimal or graphical ISO)
|
||||
- Machine on the network (Ethernet or Wi‑Fi)
|
||||
- Console or existing SSH access
|
||||
NixOS installed, machine on the network, console or SSH.
|
||||
|
||||
## 2. Hostname
|
||||
|
||||
In your config (e.g. `/etc/nixos/configuration.nix` or a flake module):
|
||||
|
||||
```nix
|
||||
networking.hostName = "myserver";
|
||||
```
|
||||
|
||||
## 3. User
|
||||
|
||||
Define a user in `users.users` (e.g. `danny` or `admin`). For key-only login you can leave the password empty or set a hashed one.
|
||||
|
||||
```nix
|
||||
users.users.danny = {
|
||||
isNormalUser = true;
|
||||
extraGroups = [ "wheel" "networkmanager" ];
|
||||
# Optional: hashed password, or omit for key-only login
|
||||
# hashedPassword = "..."; # mkpasswd -m sha-512
|
||||
# hashedPassword = "..."; # or omit for key-only
|
||||
};
|
||||
```
|
||||
|
||||
## 4. SSH
|
||||
|
||||
Enable OpenSSH and add your public keys so you can log in without a password.
|
||||
|
||||
```nix
|
||||
services.openssh.enable = true;
|
||||
|
||||
users.users.danny.openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAA... your-key-comment"
|
||||
# Add more keys (e.g. from ~/.ssh/id_*.pub on your client)
|
||||
];
|
||||
```
|
||||
|
||||
Optional hardening (disable password auth, restrict root):
|
||||
|
||||
```nix
|
||||
services.openssh.settings = {
|
||||
PasswordAuthentication = false;
|
||||
PermitRootLogin = "no";
|
||||
};
|
||||
```
|
||||
Optional: `services.openssh.settings = { PasswordAuthentication = false; PermitRootLogin = "no"; };`
|
||||
|
||||
## 5. Apply and test
|
||||
|
||||
Rebuild and switch:
|
||||
|
||||
```bash
|
||||
sudo nixos-rebuild switch
|
||||
# or: sudo nixos-rebuild switch --flake /path/to/dotfiles/nixos#hostname
|
||||
```
|
||||
|
||||
If you use a flake:
|
||||
|
||||
```bash
|
||||
sudo nixos-rebuild switch --flake /path/to/dotfiles/nixos#hostname
|
||||
```
|
||||
|
||||
From your main machine, test:
|
||||
|
||||
```bash
|
||||
ssh danny@myserver
|
||||
```
|
||||
|
||||
Replace `danny` and `myserver` with your user and hostname.
|
||||
Then from your main machine: `ssh danny@myserver`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue