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
-
login to your remote server with ssh as root:
ssh root@server-ip -
adduser your-sudo-user -
usermod -aG sudo your-sudo-user -
copy over ssh key from root to sudo user:
rsync --archive --chown=your-sudo-user:your-sudo-user ~/.ssh /home/your-sudo-user -
login remotely with your sudo user!
ssh your-sudo-user@server-ip
extras
- check who you are with
whoami - switch users with
su(short for switch user):su - your-sudo-user/su - root - for setups where you ssh into your server with password link