Connecting to a Linux Instance
You connect to a running Linux instance by using a Secure Shell (SSH) connection.
The steps to connect to a Linux instance vary, depending on the operating system that you're connecting from.
Most UNIX-style systems include an SSH client by default. Windows 10 and Windows Server 2019 systems should include the OpenSSH client, which you need if you created your instance using the SSH keys generated by Oracle Cloud Infrastructure. For other Windows versions, you can download a free SSH client called PuTTY from http://www.putty.org.
For troubleshooting suggestions, see Troubleshooting the SSH Connection. For permissions, see Required IAM Policy for Working with Instances.
No SSH key: Your instance must have SSH keys in order for a host to connect. If you created an instance without an SSH key, do one of the following:
- Terminate the instance and launch a new instance with the SSH keys included, see Creating an Instance.
- Stop the instance, attach the boot volume to a new instance, and configure SSH on the new instance.
- Use the serial console to boot into maintenance mode and add or reset the SSH key for the opc user or reset the password for the opc user.
Before You Begin
You must have the following information to connect to a Linux instance:
- Public IP address: The public IP address of the instance. You can get the address from the Instance Details page in the Console. Open the navigation menu and click Compute. Under Compute, click Instances. Then, select your instance. Alternatively, you can use the Core Services API ListVnicAttachments and GetVnic operations.
- Username: The default username for the instance.
If you used an Oracle Linux or CentOS platform image to create the instance, the username is
opc
. If you used an Ubuntu platform image to create the instance, the username isubuntu
. - SSH private key: The full path to the private key portion of the SSH key pair that you used when you created the instance. For more information about key pairs, see Managing Key Pairs on Linux Instances.
- To ensure that your SSH keys are created or uploaded, see Creating an Instance.
- SSH permissions: Ensure that permissions for the SSH folder and keys are set correctly for your OS as described in the following sections.
Connecting to a Linux Instance from a Unix-Style System
Connecting from macOS Ventura using OpenSSH 9.0: If you connect to an instance from a client running macOS Ventura (version 13) or a client running OpenSSH 9.0, you might encounter a connection issue. For more information and a workaround, see the known issue SSH connection issues with macOS Ventura using OpenSSH 9.0.
-
Use the following command to set the file permissions so that only you can read the file:
chmod 400 <private_key_file>
<private_key_file> is the full path and name of the file that contains the private key associated with the instance you want to access.
-
Use the following SSH command to access the instance.
Note
Copy the following example to ensure the correct characters are used. If the wrong character is used inssh -i
, an error such asCould not resolve hostname ...: No such host is known
might occur.ssh -i <private_key_file> <username>@<public-ip-address>
<private_key_file> is the full path and name of the file that contains the private key associated with the instance you want to access.
<username> is the default username for the instance. For Oracle Linux and CentOS images, the default username is
opc
. For Ubuntu images, the default username isubuntu
.<public-ip-address> is the instance's IP address that you retrieved from the Console.
- If you're connecting to this instance for the first time, you need to accept the fingerprint of the key. To accept the fingerprint, type yes and press Enter.
- Type
exit
at the shell prompt to end the session.
Connecting to a Linux Instance from a Windows System Using OpenSSH
If the instance uses a key pair that was generated by Oracle Cloud Infrastructure, then use the following procedure.
-
If this is the first time you are using this key pair, then you must set the file permissions so that only you can read the file. Do the following:
- In Windows Explorer, navigate to the private key file, right-click the file, and then click Properties.
- On the Security tab, click Advanced.
- On the Permissions tab, for Permission entries, under Principal, ensure that your user account is listed.
- Click Disable Inheritance, and then select Convert inherited permissions into explicit permissions on this object.
- For Permission entries, select each permission entry that isn't your user account and click Remove.
- Ensure that the access permission for your user account is Full control.
- Save your changes.
-
To connect to the instance, open Windows PowerShell and run the following command:
Note
Copy the following example to ensure the correct characters are used. If the wrong character is used inssh -i
, an error such asCould not resolve hostname ...: No such host is known
might occur.ssh -i <private_key_file> <username>@<public-ip-address>
<private_key_file> is the full path and name of the
.key
file that contains the private key associated with the instance you want to access.<username> is the default username for the instance. For Oracle Linux and CentOS images, the default username is
opc
. For Ubuntu images, the default username isubuntu
.<public-ip-address> is the instance's IP address that you retrieved from the Console.
- If you're connecting to this instance for the first time, you need to accept the fingerprint of the key. To accept the fingerprint, type yes and press Enter.
- Type
exit
at the shell prompt to end the session.
Connecting to a Linux Instance from a Windows System Using PuTTY
SSH private key files generated by Oracle Cloud Infrastructure are not compatible with PuTTY. If you use a private key file that was generated during the instance creation process, you must convert the file to a .ppk
file before you can use it with PuTTY to connect to the instance.
If you changed the file permissions on the key to connect from a Windows system using OpenSSH, then the key will not work with a PuTTY connection. Use OpenSSH to connect instead.
Convert a generated .key private key file:
-
Open PuTTYgen.
-
Click Load, and select the private key that was generated when you created the instance. The extension for the key file is
.key
. -
Click Save private key.
-
Specify a name for the key. The extension for new private key is
.ppk
. -
Click Save.
Note
PuTTYgen does not overwrite the.key
file but creates an additional file of the same name with the.ppk
extension.
Connect to the Linux instance using a .ppk private key file:
If the instance uses a key pair that you created using PuTTY Key Generator, use the following procedure.
- Open PuTTY.
-
In the Category pane, select Session and enter the following:
-
Host Name (or IP address):
<username>@<public-ip-address>
<username> is the default username for the instance. For Oracle Linux and CentOS images, the default username is
opc
. For Ubuntu images, the default username isubuntu
.<public-ip-address> is the instance's public IP address that you retrieved from the Console
- Port: 22
- Connection type: SSH
-
- In the Category pane, expand Window, and then select Translation.
- In the Remote character set menu, select UTF-8. The default locale setting on Linux-based instances is UTF-8, and this configures PuTTY to use the same locale.
- In the Category pane, expand Connection, expand SSH, expand Auth, and click Credentials.
-
Click Browse, and then select the
.ppk
private key file. -
Click Open to start the session.
If this is the first time connecting to the instance, then you might receive a message that the server's host key isn't cached in the registry. Click Yes to continue the connection.
- Type
exit
at the shell prompt to end the session.
If the connection fails and you are not behind a proxy, then ensure that Proxy type in the PuTTY configuration is set to None. If you are behind a proxy, then select the proxy type and enter the proxy host name and port number. See also Update PuTTY tool for other PuTTY issues.