Approach 4: Connect via SSH to the Compute Instance Private IP Address using a SSH Private Key with OCI Cloud Shell
In this approach, we will connect to the Linux instance using the OCI Cloud Shell provided by OCI and connect to the instance using the private IP address.
- Log in to the OCI Console and click on the OCI Cloud Shell icon to open the Cloud Shell console.
- Click Cloud Shell.
Make sure that the Cloud Shell window opens.
- Enter 'N' to skip the tutorial for now.
In order to connect to the Linux instance using the private IP address, it is important that the Cloud Shell gets access to the same subnet as where the Linux instance is connected to.
We can do this by plugging the Cloud Shell into the same VCN and subnet where the Linux instance also resides. By default the network is set to Public, but we are going to change this by creating a new private network on the fly.
- Click Network and select Private network definition list.
- Click Create private network definition.
- In Create private network definition, enter the following information.
- Enter a Name.
- Select the corresponding VCN where the Linux instance resides in.
- Select the Subnet where the Linux instance resides in.
- Select Use active network to activate the private network right away.
- Click Create.
- Notice that the status of the network will change to the newly created private network with Connecting. This will take a few seconds to complete.
- Private network is connected.
- Click Close to close the private network definition list.
- Run the
ls-lcommand and see that we do not have the private key in the home folder. - To upload the private key, click the wheel.
- Click Upload.
- Click Select from your computer.
- Click Upload.
- Select the private key from the local computer.
- Click Open.
- Review the key selected in the previous step.
- Click Upload.
- Make sure the upload is completed.
- Click Hide.
- Run the
ls-lcommand to check the private key.
- Restrict permissions of the private key and make sure the access is restricted before it can be used.
- Connect to the instance using the SSH command and specify the private key.
- Run the following command to verify the IP address.
- Verify the IP address.
- Minimize the Cloud Shell console.
- Cloud Shell console is minimized. Click Restore to restore the Cloud Shell console.
- Review the restored Cloud Shell console. Click X to close the Cloud Shell window.
- Click Exit to close the Cloud Shell window.
Now, we are back in the instance overview.