top of page

Connect Linux Instance with SSH Keys

Learn how to securely connect to Linux instances using SSH keys.

Using passwords for remote Linux access is outdated and risky, leaving systems vulnerable to hacking. The SSH Key based login is the most secure and safest way to connect a remote Linux server. If you have the key, you are in!




Connect to Linux Server from Mac


You must have SSH Key with .pem extension to connect from Mac

Download the .pem key file, open Terminal app and navigate to Downloads folder

cd ~/Downloads

Set the permissions of your PEM file

chmod 600 <key_name>.pem

Connect to the remote server using the SSH command

ssh -i <key_name>.pem cloud-user@<ip_address>

Type yes and enter the passphrase (if asked) for the SSH key. Enjoy!



Invoke Linux GUI on Mac


Download and install XQuartz package which will invoke Linux GUI on Mac. Start XQuartz, open terminal and connect to your Linux instance using SSH with -Y parameter

ssh -i <key_name>.pem -Y cloud-user@<ip_address>


Connect From Windows Using OpenSSH


You must have SSH Key with .pem extension to connect from Windows using OpenSSH. You must be running at least Windows Server 2019 or Windows 10 (build 1809) and PowerShell 5.1 or later

Install OpenSSH on Windows machine to SSH into any remote Linux server:


  • Open Settings, select System, then select Optional Features

  • Check if OpenSSH is already installed, else click Add a feature

  • Find OpenSSH Client and Install


Open cmd and navigate to the folder which contains .pem key

cd downloads

Connect to the remote server using the SSH command

ssh -i <key_name>.pem username@<ip_address>

Type yes and enter the passphrase (if asked) for the SSH key. Enjoy!




Connect From Windows Using PuTTY


You cannot use .pem file with PuTTY to connect remote Linux server. You will have to first convert the .pem file into .ppk (Putty Private Key) format and this is done through PuTTYgen software.

Convert .pem to .ppk


Install PuTTYgen from the SSH website and Start PuTTYgen. Under Actions section, click Load

By default, PuTTYgen displays only files with .ppk extension. To locate your .pem file, choose the option to display files of all types

PuTTYgen displays a notice that the .pem file was successfully imported. Choose OK. To save the key in .ppk format, choose Save private key. PuTTYgen displays a warning about saving the key without a passphrase. Choose Yes



Connect via PuTTY


Open PuTTY and enter the IP address or hostname

On Left hand menu, navigate to Connection > SSH > Auth > Select Credentials. Under Private key file for authentication, click Browse and select the .ppk file

Select Session in the left hand menu, under Saved Session give a meaningful name and click on Save

You can now double click the Saved Session and connect to remote Linux server!



Invoke Linux GUI on Windows


Download and Install Xming which will allow you to invoke Linux GUI on Windows. Start the installer and Choose Multiple Windows, enter Display number 0, and click Next

Just click Next, Next and Finish the installation. Open PuTTY and enter the IP address

If you have an SSH key, On Left hand menu, navigate to Connection > SSH > Auth > Select Credentials. Under Private key file for authentication, click Browse and select the .ppk file

To enable X11 forwarding, navigate to SSH >> X11 >> Check Enable X11 forwarding

Select Session in the left hand menu, under Saved Session give a meaningful name and click on Save

Double-click the saved session, connect to Linux server and initiate any GUI application like firefox (if installed) or Oracle runInstaller



Transfer Files Using WinSCP


WinSCP allows you to transfer files from your windows system to remote Linux server. Install WinSCP and the default installation option are OK.


Start WinSCP, give Host name (or IP Address) and User name of your remote Linux instance

If you are using DBA Genesis cloud, the default username is root or cloud-user

Click Advance button, under SSH and choose Authentication. Specify the path for your .ppk key file, or choose the ... button to browse to the key pair file and Choose OK


Choose Login. To add the host fingerprint to the host cache, choose Yes.


After the connection is established, in the connection window your Linux instance is on the right and your local machine is on the left. You can drag and drop files between the remote file system and your local machine.



Share SSH Key with other user


The cloud servers are generally configured to allow a specific super user like root or cloud-user to connect using SSH key. If you would like to connect to a different user example oracle to invoke GUI, then you will have to share the SSH key with oracle user.


If you are connecting to cloud server with a super user apart from root, like cloud-user then you can simply switch to root user with sudo su -

Connect to the cloud server with super user root or cloud-user and open authorized_keys file

cat .ssh/authorized_keys

Copy the keys that you would like to share with oracle user

Switch to oracle user

su - oracle

Open the authorized_keys file and paste the keys

vi ~/.ssh/authorized_keys

If the authorized_keys file or .ssh folder does not exists then

mkdir -m 700 -p ~/.ssh

vi ~/.ssh/authorized_keys

Paste the keys, save and give 600 permissions

chmod 600 ~/.ssh/authorized_keys

Now you can login to the server with Oracle user and same SSH Key.

Become a top notch dba with DBA Genesis
Start your DBA career today
bottom of page