Springen naar inhoud


PI

How To Create A New User On Raspberry Pi

Pi New User

  • Log in a.u.b. om te beantwoorden
Geen reacties in dit onderwerp

#1 pascalbianca

pascalbianca

    Webmaster/Admin

  • Webmaster
  • 4382 berichten
    Laatst bezocht 05 feb 2020 07:09
  • LocatieSusteren, Nederland, Midden Limburg.
Inzender

Geplaatst op 17 november 2012 - 09:21

Creating a new user with Sudo privileges in Debian on raspberry pi


There is a command usermod, which could be used to do this if you first created a root password.
But there are a lot of reasons for not creating a root password (mostly security and “best practice” related – and people still disagree about it).
You can’t use usermod to modify the id you are currently using, so the only way to do it is to create a new user and give it the same privileges (ie make it a sudo user).
The easiest way to do this is from the command line…

Code:
sudo adduser username*

*username is what you want.

…where username is the name you give your new user. Then you will be asked to key in a password twice. Make your password as long as you can manage. As much of it as possible should not be real words. This makes it harder to crack by brute force attack.

Then the system will ask you for further information about the user. You can leave these fields blank if you want – just press enter. When finished it will look like this…


Bijlage  User.png   44,7K   1 downloads

Once you’ve copied the Linux image to your
Adduser will also create a home directory for the new user at /home/username
After that you can give them sudo privileges by editing the sudoers file…

Code:
sudo visudo

Use the cursor keys to navigate to the line below the entry for pi and copy it exactly, but use your new username instead of pi.

pi ALL=(ALL) ALL
john ALL=(ALL) ALL


Leave the pi entry there for now. This part of the sudoers file should look something like this, although on different installations the users may be different.



Bijlage  privelages.png   71,79K   0 downloads

Once done, you need to save the sudoers file. This is done with CTRL+K, then X. You will see something like this…

Bijlage  sudosave.gif   2,25K   1 downloads


Testing your new username

Now, before we remove the pi username, we need to make sure that the new username you just created is working properly and with sudo privileges. First you’ll have to logout of your pi account.

Code:
logout


Then login again using your new username and password…

Code:
login


One way to test your new account has sudo access is to attempt to edit the sudoers file…

Code:
sudo visudo


Bijlage  johnsudo.gif   7,15K   0 downloads

(This image is has a different user because in vnc mode i don't see my username only pi-user)

It made me type in user john’s password to access the sudo command. It won’t always ask for it.
If you want to remove the pi username from the sudoers list, you can simply delete the line containing the pi entry and then
CTRL+K, then X to save and exit. Then you’ll want to remove the pi user from the system.


Removing the pi user

If you are doing this to improve security (the world and his wife know the default username and password, after all) you might want to remove the pi user. (In the screenshots I’m removing the user john that I created for this example.) You can do this by logging into the new user account you just created, and typing…
sudo deluser pi to delete just the user account

You don’t have to, but if you want to remove the /home/pi directory as well, use…

Code:
sudo deluser-remove-home pi


Bijlage  deluser.gif   5,99K   0 downloads

(This image is has a different user because in vnc mode i don't see my username only pi-user)

This will remove nearly all traces of the pi user from the \

system, which will make it much harder for anyone to break into your pi from outside (if it’s connected, that is). I don’t want to remove my pi user as I want my screenshots on other entries to look the same as other people using the pi user, so I removed the user john instead (in case you were wondering).
So now you have made your Raspberry Pi a bit more secure. Enjoy!


[UPDATE]

It also can be done faster.


Simply do:


Code:

sudo adduser MyUser
sudo adduser MyUser sudo


This last command will add MyUser into sudo group and MyUser will then able to use sudo.
You don’t need to edit any file. :)







Ook met taq PI, Pi, New User voorzien

0 gebruiker(s) lezen dit onderwerp

0 lid(leden), 0 bezoeker(s), 0 anonieme gebruikers

Inloggen


[PI] Untitled 1

Met dank aan Jürgen voor de jarenlange inzet van visualbasic.be (anno dec 2000)
Met dank aan Mike en Ronneke voor de jarenlange inzet van vbib.be (anno dec 2010)
Met dank aan PascalBianca voor de jarenlange inzet van vbib.be (anno dec 2016)