OCI: Create Multiple Users in Windows & Linux VMs on OCI
Often we hear from customers to create multiple user logins for a VM be it Windows or Linux, this is to give private access to every login.
In this blog, we will learn how to create multiple users for a VM (Virtual Machine).
In this blog, we will be discussing about user creation on VMs in OCI (Oracle Cloud Infrastructure).
Let us start with creation of multiple user logins for Windows Virtual Machine aka Windows RDP.
Prerequisites
- Windows & Linux Virtual Machines are created and you have access to them.
2. Ingress rules in Security Lists are in place on port 3389 to access Windows RDP & port 22 to SSH to Linux VM.
Windows Virtual Machine
The default username for your VM on OCI would be OCI, which is usually the root user.
This creates the user, but we are not done yet. Will see why we are still not done.
Log in back with the root user i.e., “opc” and let us grant access to the newly created user “santhu”
Linux Virtual Machine
The default username for Linux VM is “opc”.
Login as sudo user and create a user as shown below
Now, we will verify the entry for this user in /etc/passwd file to see if UID, GUID and directory for user are created.
create Password for “santhosh” user
now exit as root user and login with “santhosh”
list the groups and add user “santhosh” to admin group
Now, when you create a custom image out of this VM and spin up a new VM, again password authentication will be disabled, because Oracle disables them due to security reason. If you want this property to be preserved while creating custom image then run the below command, so that when you create a custom image PasswordAuthentcation value remains to what you have set in /etc/ssh/sshd_config file
$ sudo chattr +i /etc/ssh/sshd_config
Then update sshd_config file where you set Password Authentication field value to yes.
Post updating the sshd_config file restart sshd using the below command for the changes to be affective.
$sudo systemctl restart sshd
NOTE: You can also follow this Oracle documentation link for creating users and groups on Oracle Linux Machine.