Configure AWS Cloud Instance for SSH access

In a previous post I explained how to set up a SQL Developer connection with SSH using a .pem key file. In this post I’ll show you how to generate the .pem file and what you have to do on your remote AWS instance in order to get this to work.

In my case, I use an EC2 instance on which my Oracle database is installed. Via the EC2 online dashboard, I created a Key Pair:

aws_keypair

After clicking Create the private key file sqldev-key.pem downloaded. Note that you can only get the key file during the creation process. You’ll never be able to re-create the key file again.
I then placed the downloaded file in a directory on my laptop. Using terminal, I then generated the public key using ssh-keygen -y. When asked for a file, I gave it the sqldev-key.pem file name. The command then output the pubic key string, which I copied to my clipboard.

In order to limit access to the instance, I created a user account with no privileges on my database host, through the command line:

I then logged in as sqldev and created the file ~/.ssh/authorized_keys, into which I pasted the key from my clipboard. I then changed the permissions of the authorized_keys file:

Now I tested the connection from my laptop:

Now that the connection is verified, I setup SQL Developer to use the new key file for my database connection. See SQL Developer SSH Connection.

 

Leave a Reply

Your email address will not be published. Required fields are marked *