Overview
When you create a virtual machine provisioned from an image, the virtual machine is configured with a default user.
You can use this document to:
- Review and connect as a default user
- Learn how to add additional users to a virtual machine
When you create a virtual machine, passwords are not set. As a result, you must generate and add SSH keys to your workload before you attempt to connect to your virtual machine. To learn more, see Generate and Add SSH Keys for a Virtual Machine.
Review and connect as a default user
The default user is based on the operating system image you used to create the virtual machine.
The default users have sudo permissions enabled.
Review the list of default users, as well as how to connect via SSH.
Operating system | Username | Connect via SSH |
CentOS | centos |
|
Rocky Linux | rocky |
|
Debian | debian |
|
Ubuntu | ubuntu |
|
Add a user
After your instance has deployed, you can add users to your instance with the adduser
command, similar to any standard Linux distribution.
The following examples display how to add the user john.
- Run the following command to add a user:
sudo adduser john
- Run the following command to set a password for the user:
sudo passwd john
- (Optional) Run the following command to add the user to the sudo group:
-
For Debian:
sudo usermod -a -G sudo john
-
For RedHat:
sudo usermod -a -G wheel john
-
For Debian:
- Since password logins are disabled, you must add a public SSH key for the new user. To enforce user permissions, add the key to the new user's profile, not the root user.
-
On the virtual machine
- Run the following command to access the user:
sudo su - john
- Run the following command to edit the authorized keys file for the new user and append a public rsa key:
~/.ssh/authorized_keys
- Run the following command to access the user:
-
On a remote machine with root virtual machine access
- Run the following command to access the user:
ssh-copy-id john@vm_ip_address
- Run the following command to access the user:
-
On the virtual machine
- You have added a new user to the virtual machine and can modify permissions and access.