Hello folks, what is the default username and password for nixos for raspberry pi?

What is the default username and password for the most recent raspberry pi image? i see root and nixos in /etc/passwd but i don’t know the password. i also don’t have a micro hdmi yet to use.

arm image: Hydra - nixos:trunk-combined:nixos.sd_image.aarch64-linux
nix.dev : Installing NixOS on a Raspberry Pi — nix.dev documentation

if you followed the guide and ran nixos-rebuild switch then your username is whatever you set in the config:

let
  user = "guest";
  password = "guest";

You can run sudo -i to get a root shell as stated in the nix.dev tutorial if you haven’t yet installed. But I gather you’re trying to ssh in since you don’t have a HDMI cable? in any case, sudo -i should work for what you need

that is if you have a monitor connected to the raspberrypi.

power it on.

You should be greeted with a fresh shell!

you will be automatically logged in. i have not logged in to it at all. i am trying to ssh into it because i don’t have a monitor and a micro hdmi cable.

right, sshd isn’t started by default. I’m not sure if the serial console (UART) is enabled by default either but that would require a different cable. Worth a shot if you have one.

have a look at this NixOS on a Raspberry Pi: creating a custom SD image with OpenSSH out of the box | Roberto Frenna - you can probably enable sshd by default by building a custom sd image
Here’s the repo: GitHub - Robertof/nixos-docker-sd-image-builder: Build custom SD images of NixOS for your Raspberry Pi (or any other supported AArch64 device) in 5-20 minutes.
I think I followed this approach some time ago and it worked. Oh, and according to that repp

since (NixOS 20.09), OpenSSH is now enabled by default in pre-built NixOS SD images

Just a matter of copying in the right key pair

If you would like to continue the installation from a different machine you can use activated SSH daemon. You need to copy your ssh key to either /home/nixos/.ssh/authorized_keys or /root/.ssh/authorized_keys (Tip: For installers with a modifiable filesystem such as the sd-card installer image a key can be manually placed by mounting the image on a different machine). Alternatively you must set a password for either root or nixos with passwd to be able to login.

it seems its sshd is enabled because it asks me to enter username and password. (even though the guide instructs about enabling ssh, inferring that it is not enabled )

Yep, you are correct. sd image have it enabled and you’re clearly seeing it work. That nix.dev doc should be updated perhaps. See my edits above. It’s just a matter of mounting the sd card and copying your keys

i cannot access /root - permission denied. i will try putting my keys in /home/nixos

it is still asking for password even if i explicitly indicate a private key.
i could disable password authentication in /etc/ssh/ssh_config, but that is a symlink to configuration in /nix/store.
i don’t know exactly what these hashed things are but i am guessing that they are generated using nixos-rebuild switch, which i can’t do since i can’t even authenticate.
am i right?

did you load up the keys for “nixos” user?

The installer starts with a “nixos” user to allow installation, so add the SSH key to
that user. Note that the key is, at the time of writing, put in /etc/ssh/authorized_keys.d

It’s not ideal, but at this point I’d try making a custom sd image. Strange that it’s still asking for a password

it still did not work. i will try to create a custom sd image.

Cool. Let us know how it goes or if you need any assistance. I’ve found it’s easy with flakes but works without too, of course. Just a matter of remembering the commands (or just having a good reference or two) . Here’s a few resources:
GitHub - lucernae/nixos-pi: How to install NixOS on raspberry PI (no flakes)
GitHub - rjpcasalino/pie (flakes)
myme.no - NixOS: On Raspberry Pi 3B

putting the public key in /home/nixos/.ssh/authorized_keys actually works.
I made a little mistake in the directory that last time.
Thanks

1 Like

Could someone clarify - how exactly I should put this authorized_keys to SD media?
I flash it with the pre-made minimal .iso image, so no rw partitions exist there by default, right?
Where should I put the file then?

EDIT:
I’m about SD media for x86_64.