DEV Community

Clark Weckmann
Clark Weckmann

Posted on • Originally published at weckmann.me on

Change Default Pi Username

If you’re using Raspbian your default username is pi. In this article, I will teach you how to change this username, the password, and remap the home directory. To do this you must first log in as the root user. By default, the root user has no password enabled. Log in as the pi user and enter this command.

$ sudo passwd root

Enter fullscreen mode Exit fullscreen mode

You should choose a safe and secure password for this user. After you change the pi username to your desired username I recommend disabling the root password. Make sure password login for root is enabled by editing the sshd_config file.

$ sudo nano /etc/ssh/sshd_config

Enter fullscreen mode Exit fullscreen mode

Find PermitRootLogin without-password it could say something similar. Change this value to PermitRootLogin yes.

You can now logout of the pi user by entering this command.

$ logout

Enter fullscreen mode Exit fullscreen mode

If this command fails to work use the exit command.

Login as the root user now with the password you created.

We need to modify the name of the pi user now. Run this command. Replace newuser with your desired username.

usermod -l newuser pi

Enter fullscreen mode Exit fullscreen mode

We need to modify the home directory now to match the new username. Again replace newuser with your desired username.

usermod -m -d /home/newuser newuser

Enter fullscreen mode Exit fullscreen mode

You can now logout of the root user and log back in as the username you just created. The password for your username is still the default username for pi, “raspberry”. If you wish to change this enter this command.

passwd

Enter fullscreen mode Exit fullscreen mode

Now enter “raspberry” as the Current Password and then your desired password for New Password and confirm.

If you wish to lock the root user password for security reasons you can enter the following.

sudo passwd -l root 

Enter fullscreen mode Exit fullscreen mode

You’re all set! Enjoy your new username.


Reply via email

Top comments (0)