Many times we have talked about creating projects with our Raspberry Pi open to the public. Even many users do is connect several Raspberry Pi boards to have a small but powerful server as a result. The problem that many users have is that the Pi user remains and therefore their projects are vulnerable since knowing the administrator user, it is easy to know the password.
For this reason we are going to tell you how to change Pi user and password, making our Raspberry Pi board and our projects safer than ever and we can use it without any problem and open to the public.
I know the important thing is to change the Pi user, but first of all, let's try easy things. So first we are going to change the password. There are two options, one of them is to use the Rasp-config script, a process that is long and complicated. The second option is to use the terminal and type the following:
This command it will ask you for the new password and repeat the new password, to ensure that we have entered the new password correctly.
This last method is simple and quick to do.
Change user Pi
Now comes the most important change. In this case we have to use the terminal. First we have to enable the root user which is disabled by default and then, from the root user, change the Pi user. So, in the terminal we write the following:
sudo passwd root
This will not only enable the root user but will change the root password. Once we have changed it, we enter as root and type the following:
usermod -l NUEVO_USUARIO pi -md /home/NUEVO_USUARIO
Where we have put "new user" we have to put the new user that we want to put. Then we have to change the password or keep it, in any case, the password will be the same as the root user. Something that should be known and that is important. Now, we have to change the group to user Pi, a user who is still on the machine. To do this we write the following in the terminal:
groupmod -n <nombre nuevo del grupo> pi
The new group, if possible, that is not one in which our user is. Once this is done, we are going to disable the root user (remove the password), so that only our user remains as unique. To do this we write in the terminal:
sudo passwd –l root
Personally, I recommend you change the password as well, thus creating a new user with a new password as well and of course doing the latter. A) Yes the security of our device will be the highest possible and it will be difficult for strangers to enter our projects.