From a34145b912e2635234d3d49af480b791d2bb0585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cyryl=20P=C5=82otnicki?= Date: Tue, 1 Nov 2022 10:48:16 +0000 Subject: [PATCH] Add post on non-standard ssh port for a nix build host --- .../2022/11/ssh-port-distributed-builds.md | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 content/posts/2022/11/ssh-port-distributed-builds.md diff --git a/content/posts/2022/11/ssh-port-distributed-builds.md b/content/posts/2022/11/ssh-port-distributed-builds.md new file mode 100644 index 0000000..af176eb --- /dev/null +++ b/content/posts/2022/11/ssh-port-distributed-builds.md @@ -0,0 +1,30 @@ +--- +title: How to use a non-default ssh port for a Nix distributed build host +date: 2022-11-01 +tags: [nix] +--- + +I wanted to host my ssh server on a different port than the default `22`, this allows me to skip on some spam in the logs, as the default port gets scanned quite often. +By changing that on the server I broke distributing my nix builds, as they were using the default port as well. +It took me a while to figure out how to configure the port the builder would use so I thought I would share here. + +Here's an example of a *client-side* configuration - using a build server `buildHostName` with a user named `nix-builder`, connecting via ssh to port `1234`. +```nix +programs.ssh.extraConfig = '' + Host buildHostName + HostName buildHostName + Port 1234 + StrictHostKeyChecking=accept-new +''; + +nix.buildMachines = [{ + hostName = "buildHostName"; + sshUser = "nix-builder"; + sshKey = "/path/to/key"; + systems = [ "x86_64-linux" ]; + maxJobs = 2; + speedFactor = 2; + supportedFeatures = [ "kvm" ]; + mandatoryFeatures = [ ]; +}]; +```