ubuntu@ip-172-31-37-13:~$ sudo adduser foouser
Adding user `foouser' ...
Adding new group `foouser' (1006) ...
Adding new user `foouser' (1006) with group `foouser' ...
Creating home directory `/home/foouser' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for foouser
Enter the new value, or press ENTER for the default
Full Name []: Foo Bar
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
ubuntu@ip-172-31-37-13:~$
run: sudo su {{username}}
Note: when command runs succesful the bash promt name
changes from your user to the new user.
See below, bash changes from ubuntu
to foouser
ubuntu@ip-172-31-37-13:~$ sudo su foouser
foouser@ip-172-31-37-13:/home/ubuntu$
foouser@ip-172-31-37-13:/home/ubuntu$ cd ~
foouser@ip-172-31-37-13:~$ pwd
/home/foouser
foouser@ip-172-31-37-13:~$
foouser@ip-172-31-37-13:~$ mkdir .ssh
foouser@ip-172-31-37-13:~$ chmod 700 .ssh/
foouser@ip-172-31-37-13:~$ cd .ssh/
foouser@ip-172-31-37-13:~/.ssh$ nano authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC52LoTJqmrEl4qDtH231rtmfJjHgbu3fbk+Yaq2szP5KEIw0Mr96DN40d9//RgHUgeuwROqNJwF6Y7nmp1ljnJW5O60YM9GhrsBN1k6DA2+2oCQH0n7UZWI/Q1k/kpwC/Ec0Rb664+Lu6sow0C$
foouser@ip-172-31-37-13:~/.ssh$ chmod 600 authorized_keys
Exit the new users terminal to return to your own user terminal
foouser@ip-172-31-37-13:~/.ssh$ exit
exit
ubuntu@ip-172-31-37-13:~$
you have succesfully created new user and added their public key to server
sudo usermod -aG sudo foouser
sudo usermod -aG www-data foouser