The default user on a fresh Raspbian is pi with the password raspberry. To feel a little bit more save I would like to delete the user pi and change the default root user password.
To bypass the hassle of connecting the Raspberry Pi with a screen and a keyboard I mostly just connect the Raspberry Pi to my router. Normally the pi should register itself as raspberrypi at the router. So we can connect via ssh. If you have connected your Raspberry Pi with a screen and a keyboard you can skip this step and just login as pi.
The pi user has super-user rights so we can switch to the root user.
Let's create a new user. In my case I just name the user gordon.
adduser gordon Adding user `gordon' ... Adding new group `gordon' (1001) ... Adding new user `gordon' (1001) with group `gordon' ... Creating home directory `/home/gordon' ... Copying files from `/etc/skel' ... Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Changing the user information for gordon Enter the new value, or press ENTER for the default Full Name : Gordon Lesti Room Number : Work Phone : Home Phone : Other : Is the information correct? [Y/n]
Raspbian has sudo preinstalled as we have already used it above. So we just need to add the new user to the sudo group.
adduser gordon sudo Adding user `gordon' to group `sudo' ... Adding user gordon to group sudo Done.
Let's add our own public ssh key to the file /home/gordon/.ssh/authorized_keys so that we can connect via ssh without a password in future. We need to create the directory /home/gordon/.ssh and change the user to the new one. Again, if you have screen and a keyboard connected to the Raspberry Pi, you can skip this step.
mkdir /home/gordon/.ssh chown gordon:gordon /home/gordon/.ssh/
After that we will exit from the Raspberry Pi.
exit logout Connection to raspberrypi closed.
Now we will create the file /home/gordon/.ssh/authorized_keys on the Raspberry Pi via scp. Hopefully you have public ssh key on your current computer at ~/.ssh/id_rsa.pub.
scp ~/.ssh/id_rsa.pub gordon@raspberrypi:/home/gordon/.ssh/authorized_keys gordon@raspberrypi's password: id_rsa.pub 100% 401 0.4KB/s 00:00
After that we should now connect again with our new user via ssh without a password. Or if screen and keyboard are connected to the Raspberry Pi, you just login as the new user.
Let's remove the user pi and check our super-user permissions.
sudo deluser pi [sudo] password for gordon: Removing user `pi' ... Warning: group `pi' has no more members. Done.
Let's change the root user password and we are fine for now.
sudo passwd root Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully