Rapsberry Pi is the single most popular computer in the world. And it is easily one of the most hacked systems as well. That’s due to single fact – most users never change the default username and password. But is a relatively a simple process, so there is no reason not to do it. If you already have your Raspberry Pi up and running, you can get going.
Changing the hostname
First of all, change the hostname. This has two benefits: it will make it slightly harder for hackers to identify your Pi, and it will also any prevent any clashes on network if you have multiple Raspberries.
So, fire up
pi@raspberrypi$ sudo raspi-config
And choose the option “Change the Hostname”. Then type in the new hostname (for example fileserver, webserver) and confirm it. Done.
Change the username and password
Next on the chopping block is username. Since renaming user is a bit of a hassle, just create a new one and lock the
pi account. (Substitute
newuser for your desired username.)
pi@raspberrypi$ sudo useradd newuser -m -g pi
pi@raspberrypi$ for GROUP in $(groups pi | sed ‘s/.*:\s//’); do sudo adduser newuser $GROUP; done
The new user should be set up and have the same priviledges as
pi. All that remains is changing the password:
pi@raspberrypi$ sudo passwd dak
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Finally, login to the new user account to check if everything is working as expected:
pi@raspberrypi$ su newuser
If you don’t encounter any trouble, go ahead and lock the
newuser@raspberrypi$ sudo passwd -l pi
Hostname, username, password – everything is changed. Now you can sleep tight, knowing that the hackers cannot simply login to your Pi as if it were their own.