Skip to content

How to add new user and remote root login

Daisho Komiyama edited this page Jul 27, 2020 · 7 revisions

Leaving root user login available isn't good practice when it comes to server setup. Today I'm going to walk through how to add new user then remove root user login.

  • First, login to your server using root
  • Then update your server apt update then apt upgrade (upgrade might take a few minutes)

Create new user

  • adduser daisho
  • Enter new UNIX password (you can skip this if you are going to set up ssh key)
  • You can leave blank the rest: entering user information

Switch user

  • su daisho

Verify if daisho has superuser access (auth.log is available only to superusers)

  • cat /var/log/auth.log you will get permission denied

Again with "sudo"

  • sudo cat /var/log/auth.log this should be successful

Setting user permissions

  • Go to home directory: cd ~

  • Create .ssh directory: mkdir -p ~/.ssh

  • Create authrized_keys file and paste PUBLIC key (generated in your local machine)

  • If you have multiple public keys, just paste them in the same file on new line

Clone this wiki locally