I made the mistake of changing of the pi user name string to something else (e.g. foo) in /etc/passwd. I did not change the home directory. Now when I try to log in via ssh to the new user, sshd immediately closes the connection (I have my ssh public key in /home/pi/.ssh/autorized_keys). If I try to log in as pi, it asks for a password, but then fails to authenticate.

I can easily modify the boot partition (it mounts on macOS). Is there any way to set things up so I can log in, perhaps via serial console, to fix /etc/passwd? Or is my only hope to mount the entire filesystem (e.g. on a Debian VM) and edit /etc/passwd?


I was able to mount the boot drive on a Debian VM and edit /etc/passwd to restore the username to pi, but any attempt to connect ssh pi@<ip address> is immediately refused. And the device no longer seems to advertise its mDNS name. The Docker containers are running, though. I’m very confused.

  • 1
    Why would someone downvote this question? It's a perfectly valid question, even if it does describe a mistake. There was a time when unix would have perfectly accepted this change.
    – Rick
    Jan 9, 2022 at 6:39
  • probably because the question is not about Raspberry Pi, but about Linux ... it does not belong here
    – jsotola
    Jan 9, 2022 at 8:35
  • That seems like splitting hairs, but okay, I'll go elsewhere.
    – Rick
    Jan 9, 2022 at 9:28
  • 2
    @Rick sorry that you experience this. I can second, this stackexchange is very unfriendly with a lot of unwanted gate keeping, there are much more positive communities (e.g. tex.stackexchange is amazing). I recommend to use forums instead.
    – 0__
    Jan 9, 2022 at 22:35
  • 1
    @0__ Yeah, I’ve never experienced this on other SE sites, and as a professional software engineer, I use them frequently.
    – Rick
    Jan 9, 2022 at 23:07

2 Answers 2


Instead of trying to SSH in remotely, could you try connecting a keyboard and monitor temporarily to the raspi and log in locally?

  • No, not really, I don't have a monitor or keyboard handy, just a laptop and serial cable. That's why I'm looking for this solution.
    – Rick
    Jan 9, 2022 at 4:58

It is difficult to see what you hoped to achieve by changing the pi user name string (this is a totally new way to screw up your OS).

You can remove the password by changing pi:x:1000:1000: to pi::1000:1000: This is simple with a monitor/keyboard.

Whether this will work over ssh is unknown.

Normally logging in as a root shell is the way to fix problems but this requires a monitor/keyboard as ssh root access is prohibited.

Frankly the best way is to restore from your backup.

  • I had hoped to achieve changing the name of the user without first creating another user just to allow usermod to function. This was once a perfectly reasonable way to change a username.
    – Rick
    Jan 9, 2022 at 6:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.