Rename default pi user
After installing Raspbian Lite on a Raspberry PI, the default user pi is a liability. To fix this, a possibility is to create a new user and delete the old pi user, but I like recycling, so I’ll just rename the user.
First we need to allow root login over ssh;
- Add
PermitRootLogin yesto /etc/ssh/sshd_config - Change the password of the root user
$ sudo passwd root - Restart ssh
$ sudo service ssh restart
Second login to the raspberry with root and execute the following;
- Kill all processes started by
pi$ pkill -u pi$ pkill -9 -u pi
$ usermod -l new_username pi$ groupmod -n new_username pi$ usermod -d /home/new_username new_username- Remove
PermitRootLogin yesfrom /etc/ssh/sshd_config - Remove the root password
$ passwd -d root - Restart the raspberry pi
$ reboot
Reply