I’m trying to set up a server running NixOS. I’ve never set up a server of any kind before, although I’ve used plenty of clients.
My client (“hp17”, a Hewlett Packard laptop from 2017) doesn’t even see my server, let alone connect.
# bash from client
[jeff@jbb-hp17:~/code/phan]$ nmap 181.56.238.79
Starting Nmap 7.92 ( https://nmap.org ) at 2022-05-09 19:15 -05
Note: Host seems down. If it is really up, but blocking our ping probe
s, try -Pn
Nmap done: 1 IP address (0 hosts up) scanned in 3.08 seconds
[jeff@jbb-hp17:~/code/phan]$ ssh jeff@181.56.238.79
<Hangs until I terminate it, with no output.>
Here are all the relevant passages from the server’s config, plus maybe a few that aren’t:
# configuration.nix on server
# Enable the OpenSSH daemon.
services.openssh = {
enable = true;
passwordAuthentication = true;
# I'll disable this once I can connect.
};
# Open ports in the firewall.
networking.firewall.allowedTCPPorts = [ 22 ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
networking.hostName = "server-2022";
networking.networkmanager.enable = true;
networking.useDHCP = false;
networking.interfaces.enp1s0.useDHCP = true;
networking.interfaces.wlp2s0.useDHCP = true;
users.users.jeff = {
uid = 1000; # for compatibility with Ubuntu
isNormalUser = true;
extraGroups = [
"wheel"
"networkmanager"
"dialout"
];
};
# Enable the X11 windowing system.
services.xserver.enable = true;
services.xserver.layout = "us";
services.xserver.xkbOptions = "eurosign:e";
# Enable the KDE Desktop Environment.
services.xserver.displayManager.sddm.enable = true;
services.xserver.desktopManager.plasma5.enable = true;
I’ve already logged in on that server as jeff (the same user that I want to ssh in as from another computer), connected to the wifi network (on which other computers are sometimes hosted too), determined its IP address, and perhaps unnecessarily started sshd.service
by hand:
# bash on server
jeff@server-2022:~$ curl ifconfig.me
181.56.238.79
jeff@server-2022:~$ sudo systemctl start sshd.service
[sudo] password for jeff:
jeff@server-2022:~$
I’ve tried with my client laptop on the same network or on another one. (I can connect to AWS using that client from either network, so I know that’s not the problem.) I’ve tried connecting both before running sudo systemctl start sshd.service
and after, thinking maybe that procedural action interferes with NixOS’s declarative idiom.
Is systemctl start
unnecessary? That is, will the SSH daemon start automatically when I log in? Can I make the daemon start before I log in, so that I can keep it offsite and if someone reboots it I can still log in from afar?