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

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

  2. 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 in ssh -i, an error such as Could 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 is ubuntu.

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

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

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

    1. In Windows Explorer, navigate to the private key file, right-click the file, and then click Properties.
    2. On the Security tab, click Advanced.
    3. On the Permissions tab, for Permission entries, under Principal, ensure that your user account is listed.
    4. Click Disable Inheritance, and then select Convert inherited permissions into explicit permissions on this object.
    5. For Permission entries, select each permission entry that isn't your user account and click Remove.
    6. Ensure that the access permission for your user account is Full control.
    7. Save your changes.
  2. 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 in ssh -i, an error such as Could 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 is ubuntu.

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

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