Skip to content

Instantly share code, notes, and snippets.

@m1cr0man
Last active February 1, 2025 17:32
Show Gist options
  • Save m1cr0man/d7165e57e13aca77fde3a61527a40da4 to your computer and use it in GitHub Desktop.
Save m1cr0man/d7165e57e13aca77fde3a61527a40da4 to your computer and use it in GitHub Desktop.
SSH to a nixos test container
# This gist pertains to entering test VMs within nixpkgs/nixos/tests
# They must be run with driverInteractive in order to keep them around
# Use this in your test VM node configuration to enable ssh and root login
{
services.openssh = {
enable = true;
settings.PermitRootLogin = "yes";
};
# Password will be "testingpain"
users.users.root.hashedPassword = "$6$LXJZIXCXOFNlhzc5$NYtb4ThIXAf4tcmIZB9D0b8r4Dj52JH0WU1ZwdVXdp0lQRZBU7I7dw.6ojLZY/bpxKTqYokIvqTZA.JGKXuVY/";
users.users.root.hashedPasswordFile = null;
users.mutableUsers = false;
virtualisation.forwardPorts = [{ from = "host"; host.port = 2222; guest.port = 22; }];
}
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@localhost -p 2222
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment