11

I know that security by obscurity is not real security, however, why make it easy by keeping a well known username such as "pi".

Therefore, what are the implications to changing the username of "pi" on Raspbian and Raspbmc?

Do I need to do anything other than just editing /etc/password changing "pi" to some new string?

Researching on how to force sudo to require a password I discovered that /etc/sudoers on my Raspbmc contains an entry for "pi", so therefore I at least need to update that file accordingly.

2 Answers 2

5

Changing the user login name should work. It's just a piece of text for people to use. UID is the thing that actually identifies a user to the system. Some config files can indeed be using the name and of course the user has a home dir etc.

You shouldn't edit passwd file by hand, but by tools like vipw or usermod. Remember that there's probably a shadow system as well, so you need to make sure they're both updated properly.

I wouldn't try to rename a user but create a new one and either disable or remove the default account. Removing it risks a new user with the same uid (getting same file access etc) or login name (e.g. sudo rights) getting added later.

1
  • 1
    Thanks for your advice. I am going to create a new account and then lock the default account using passwd -l. Since I'm currently using Raspbmc this should allow the xbmc background daemons run using the default account. Commented Nov 3, 2012 at 23:01
13

It is tricky to rename an account while you are logged in to it, and easy to accidentally lock yourself out of your Pi, so first enable the root account with

$ sudo passwd root

Use a secure password, even if you intend to lock the root account again later. Then log out and log back in as root. The rest supposes a desired username of "myuname" - replace with whatever you want.

# usermod -l myuname pi
# usermod -m -d /home/myuname myuname
# groupmod -n myuname pi

This first renames the account and then moves the home directory associated with it. Then log out and log back in again as "myuname". If you are still using the default password of "raspberry" on this account, do

$ passwd

and change password to something more secure. That should be it. Test carefully! "sudo" users seem to get updated OK, but check that your renamed account works and really does have "sudo" privileges before disabling the root account.

Should you prefer to disable the root account, do

$ sudo passwd -l root

Technically, this just locks the password - it doesn't completely disable the account. But that's probably what you want.

2
  • You to fully revert enabling root (not just locking it) run sudo passwd -dl root Commented Oct 19, 2015 at 2:19
  • Word of advice: as of January 2017, if you rename the default username, the Raspberry Pi Configuration utility will refuse to run from thereon. It's easy to rename the account back to "pi", though. Commented Jan 14, 2017 at 21:20

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.