12 Accessing an Oracle Linux Instance Using SSH
If you’ve created your instance using an Oracle-provided Oracle Linux image, then you can log in to your instance using SSH as the opc
user.
If you’ve created your instance using a custom machine image, then ensure that you’ve added a script to copy SSH public keys to the appropriate files for default users. This script must run automatically when your instance starts. It must retrieve the SSH public keys from the metadata stored in the instance, and copy these keys to the following path for one or more default users: /home/user/.ssh/authorized_keys
. For information about retrieving SSH public keys, see Retrieving Instance Metadata.
Accessing an Instance from UNIX and UNIX-Like Systems
You can log in to an Oracle-provided Oracle Linux instance as the default user, opc
. The opc
user has sudo
privileges.
Prerequisites
-
Ensure that the SSH private key corresponding to the public key that you associated with your instance while creating it is available on the host from which you want to
ssh
to the instance. -
Ensure that the instance has a public IP address. See Managing Public IP Addresses. To find out the public IP address of your instance, view the information on the Instances page. See Listing Instances.
-
Ensure that a security rule exists to enable SSH access to your instance. See Creating a Security Rule for IP Networks.
If your instance is on IP network, see Workflow for Enabling SSH Access to an Instance Using IP Networks.
If your instance is on shared network, see Permitting SSH Access to Compute Classic Instances.
Procedure
You can use SSH to log in to your instance as the default user, opc
, by using the following command:
ssh opc@ip_address —i private_key
In this command, ip_address is the public IP address of the instance, and private_key is the full path and name of the file that contains the private key corresponding to the public key associated with the instance that you want to access.
Note:
If you’ve enabled a VPN tunnel to your Compute Classic instances, you can use the private IP address of your instance to connect to the instance. To set up a VPN tunnel, see Connecting to Instances in a Multitenant Site Using VPN, Setting Up VPN Using VPNaaS, or Connecting to Oracle Cloud Infrastructure Dedicated Compute Classic Instances Using VPN. (Not available on Oracle Cloud at Customer)
If an error occurs, see Can’t connect to an instance using SSH.
When you’re logged in as the default user, opc
, use the sudo
command to run administrative tasks.
Accessing an Instance from Windows
You can log in to an Oracle-provided Oracle Linux instance as the default user, opc
. The opc
user has sudo
privileges. If you’re using a Windows host, you can use PuTTY or any other similar client to connect to your instance using SSH.
Prerequisites
-
This procedure assumes you’re using PuTTY to connect to your instance. Ensure that you have PuTTY installed on your Windows host. To download PuTTY, go to http://www.putty.org/.
-
Ensure that the SSH private key corresponding to the public key that you associated with your instance while creating it is available on the Windows host from which you want to
ssh
to the instance. -
Ensure that the instance has a public IP address. See Managing Public IP Addresses. To find out the public IP address of your instance, view the information on the Instances page. See Listing Instances.
-
Ensure that a security rule exists to enable SSH access to your instance. See Creating a Security Rule.
Procedure
If an error occurs, see Can’t connect to an instance using SSH.
When you’re logged in as the default user, opc
, use the sudo
command to run administrative tasks.
Adding Users on an Oracle Linux Instance
If you’ve created your instance using an Oracle-provided Oracle Linux image, then you can use SSH to access your Oracle-provided Oracle Linux instance from a remote host as the opc
user. After logging in, you can add users on your instance.
Note:
When an instance that’s set up to boot from a nonpersistent boot disk is deleted and re-created, any users that were added manually (that is, users that weren’t defined in the machine image) must be added again.
ssh new_user@ip_address -i private_key
In this command, ip_address is the public IP address of the instance, and private_key is the full path and name of the file that contains the private key corresponding to the public key that you added to the authorized_keys
file earlier in this procedure.
Note:
If you’ve enabled a VPN tunnel to your Compute Classic instances, you can use the private IP address of your instance to connect to the instance. To set up a VPN tunnel, see Connecting to Instances in a Multitenant Site Using VPN, Setting Up VPN Using VPNaaS, or Connecting to Oracle Cloud Infrastructure Dedicated Compute Classic Instances Using VPN. (Not available on Oracle Cloud at Customer)
If an error occurs, see Can’t connect to an instance using SSH.
Use the sudo
command to run administrative tasks.