Adding Users on an Instance

You can add additional users to a Compute instance.

If you created your instance using an Oracle-provided Linux or CentOS image, you can use SSH to access your instance from a remote host as the opc user. If you created your instance using the Ubuntu image, you can use SSH to access your instance from a remote host as the ubuntu user. After signing in, you can add users to the instance.

If you created your instance using an Oracle-provided Windows image, you can create new users after you sign in to the instance through a Remote Desktop client.

Creating Additional Users on a Linux Instance

If you do not want to share your SSH key, you can create additional SSH-enabled users for a Linux instance. At a high level, you do the following things:

  • Generate SSH key pairs for the users offline.
  • Add the new users.
  • Append a public key to the ~/.ssh/authorized_keys file for each new user.
Tip

If you re-create an instance from an Oracle-provided image, users and SSH public keys that you added or edited manually (that is, users that weren’t defined in the machine image) must be added again.

If you need to edit the ~/.ssh/authorized_keys file of a user on your instance, start a second SSH session before you make any changes to the file and ensure that it remains connected while you edit the file. If the ~/.ssh/authorized_keys file becomes corrupted or you inadvertently make changes that lock you out of the instance, you can use the backup SSH session to fix or revert the changes. Before closing the backup SSH session, test all changes you made by logging in with the new or updated SSH key.

The new users then can SSH to the instance using the appropriate private keys.

To create an additional SSH-enabled user:

  1. Generate an SSH key pair for the new user.
  2. Copy the public key value to a text file for use later in this procedure.
  3. Log in to the instance.
  4. Become the root user:

    sudo su
  5. Create the new user:

    useradd <new_user>
  6. Create a .ssh directory in the new user’s home directory:

    mkdir /home/<new_user>/.ssh
  7. Copy the SSH public key that you saved to a text file into the /home/new_user/.ssh/authorized_keys file:

    echo <public_key> > /home/<new_user>/.ssh/authorized_keys
  8. Change the owner and group of the /home/username/.ssh directory to the new user:

    chown -R <new_user>:<group> /home/<new_user>/.ssh
  9. To enable sudo privileges for the new user, run the visudo command and edit the /etc/sudoers file as follows:

    1. In /etc/sudoers, look for:

      %<username> ALL=(ALL) NOPASSWD: ALL
    2. Add the following line immediately after the preceding line:

      %<group> ALL=(ALL) NOPASSWD: ALL

    The new user can now sign in to the instance.

Creating Additional Users on a Windows Instance

  1. Log in to the instance using a Remote Desktop client.

  2. On the Start menu, click Control Panel.

  3. Click User Accounts, and then click User Accounts again.

  4. Click Manage User Accounts.

  5. Click Manage Another Account.

  6. Click Add User Account.

  7. Enter a User name and Password.

  8. Confirm the password, and then create a Password hint.

  9. Click Next.

  10. Verify the account, and then click Finish.

    The new user can now sign in to the instance.