Adding sudo user from root user

this is tested on digitalocean, with ssh key access enabled and password disabled. further readings here

tested on ubuntu 18.04 on digitalocean

  1. login to your remote server with ssh as root: ssh root@server-ip
  2. adduser your-sudo-user
  3. usermod -aG sudo your-sudo-user
  4. copy over ssh key from root to sudo user: rsync --archive --chown=your-sudo-user:your-sudo-user ~/.ssh /home/your-sudo-user
  5. login remotely with your sudo user! ssh your-sudo-user@server-ip

extras