Connecting to Your Instance

You connect to a running Linux instance using a Secure Shell (SSH) connection. Most Linux and UNIX-like operating systems include an SSH client by default. Windows 10 and Windows Server 2019 systems should include the OpenSSH client, which you'll 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.

This topic describes how to connect to the instance you create in this tutorial. To connect to an instance created by someone else, ask that person to add you to the instance (see Adding Users to an Instance ).

Before You Begin

Connecting to Your Linux Instance Using SSH

Log in to the instance using SSH. Depending on the operating system that you're connecting from, use one of the following methods.

Connecting to a Linux Instance from a Unix-Style System

Use the OCI generated key pair or the key pair used to create the instance. Then use the following steps to connect to an OCI Linux instance.

  1. Open a terminal.
  2. Locate the private key file for your key pair. The default directory location for SSH keys is <your-home-directory>/.ssh.
  3. Use the following command to set the file permissions so that only you can read the file:

    Set the file permissions for the private key file so that only the current user has read-only access:

    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.

  4. Use the following SSH command to access the instance.

    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 Redhat Enterprise Linux compatible images, the default username is opc. For Ubuntu images, the default username is ubuntu.

    <public-ip-address> is the instance's IP address that you retrieved from the Console.

  5. 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.
  6. You are connected to the default shell for the instance.
  7. When you have finished your session, type exit at the shell prompt to end the session.

Connecting to a Linux Instance from a Windows System Using OpenSSH

Using the OCI generated key pair or your own generated key pair used to create the instance, connect to the Linux instance.

Set the Permissions for the Private Key File

Set the file permissions for the private key file so that only the current user has read-only access. Do the following:

  1. Locate the SSH key files you created by or created for your instance.
  2. In Windows Explorer, navigate to the private key file, right-click the file.
  3. Click Properties.
  4. On the Security tab, click Advanced.
  5. On the Permissions tab, for Permission entries, under Principal, ensure that your user account is listed.
  6. Click Disable Inheritance, and then select Convert inherited permissions into explicit permissions on this object.
  7. For Permission entries, select each permission entry that isn't your user account and click Remove.
  8. Ensure that the access permission for your user account is Full control.
  9. Save your changes.
Connect to the Instance with PowerShell

Next, connect to the instance with PowerShell.

  1. Open Windows PowerShell and run the following command:

    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 Redhat Enterprise Linux compatible images, the default username is opc. For Ubuntu images, the default username is ubuntu.

    <public-ip-address> is the instance's IP address that you retrieved from the Console.

  2. 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.
  3. You are connected to the default shell for the instance.
  4. When you have finished your session, 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.

Note

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:

  1. Open PuTTYgen.

  2. Click Load, and select the private key that was generated when you created the instance. The extension for the key file is .key.

  3. Click Save private key.

  4. Specify a name for the key. The extension for new private key is .ppk.

  5. 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.

  1. Open PuTTY.
  2. 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 is ubuntu.

      <public-ip-address> is the instance's public IP address that you retrieved from the Console

    • Port: 22
    • Connection type: SSH
  3. In the Category pane, expand Window, and then select Translation.
  4. 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.
  5. In the Category pane, expand Connection, expand SSH, expand Auth, and click Credentials.
  6. Click Browse, and then select the .ppk private key file.

  7. 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.

  8. Type exit at the shell prompt to end the session.
Note

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.

Running Administrative Tasks on the Instance

When you're logged in as the default user, opc, you can use the sudo command to run administrative tasks.

What's Next

Now that you've got an instance and have successfully connected to it, consider the following next steps:

If you're having trouble connecting, see Troubleshooting the SSH Connection.