Member-only story
How to create a user on your Ubuntu instance
1 min readJan 21, 2025
Create users that have access to a Ubuntu instance with optional permissions and SSH capabilities.
Begin creation
# on ubuntu
sudo adduser username
OPTIONAL: Give sudo power
# on ubuntu
sudo usermod -aG sudo username
OPTIONAL: Expire password
Next time the user logs in, they will be prompted to create a new password.
# on ubuntu
sudo passwd --expire username
OPTIONAL: add SSH access
If your user needs to SSH into the Ubuntu instance, you will want to add their SSH public key
If the user doesn't already have an SSH key generated, they can do so on their local machine:
# on user's local machine
ssh-keygen -t ed25519 -C "your_email@example.com"
cat ~/.ssh/id_ed25519.pub # or whatever you chose as the file path
Copy, paste, and save their public SSH key on the Ubuntu instance.
# on ubuntu
sudo mkdir /home/username/.ssh
sudo vi /home/username/.ssh/authorized_keys
They can add this to their local machine ~/.ssh/config.
# on user's local machine
vi ~/.ssh/config
Host ubuntu_name
HostName <IP ADDRESS>
User username
IdentityFile "~/.ssh/id_ed25519" # or whatever path that was chosen
They can now access the Ubuntu instance by running this on their local machine.
# on user's local machine
ssh ubuntu_name