Amazon Web Services (AWS) WordPress

How to Connect via SSH to an AWS EC2 Instance Running Bitnami WordPress

An SSH connection gives you control over the configuration of your server. From handling folder permissions to simply removing the Bitnami banner that comes enabled as standard, you’ll need SSH access to do a lot of things.

If you’ve installed WordPress on an AWS EC2 instance using a Bitnami AMI but you don’t know how to connect via SSH, let me help you with this quick guide.

Step 1: Convert Your Private PEM Key to PPK

Assuming you’ve already gone through the process of setting up your EC2 instance with WordPress installed, you should’ve downloaded your private key file when you reached the screen below.

If you haven’t got it already, download and install PuTTY. This is the most popular tool for connecting to servers via SSH, but it also comes with a handy tool called PuTTYgen which is used for generating and converting key files.

Start PuTTYgen and PuTTY Key Generator should launch, showing a small window with several options. Here, we’re looking to convert our .pem key that we downloaded into a .ppk file so that PuTTY can use it.

Click the Load button to bring up the file explorer and navigate to the directory where you stored your .pem key. You may not see your key listed there. If that’s the case, it’s because it’s only looking for .ppk files. Make sure that you change the option to display All Files using the dropdown just above the Open and Cancel buttons if you’re using Windows.

Select the .pem key and click Open to load it into PuTTYgen. You should then see a message pop up to say it’s “Successfully imported foreign key…” Great! Click OK to return to the PuTTYgen window.

You should now see the data stored in your private PEM key showing in the upper part of the tool. Seeing as this is your private key – it’s just not in the format that we need it – all we need to do is save your private key again.

Click Save private key and an alert message should pop up to confirm whether or not you’re happy to proceed without adding a passphrase to protect the key. If you want to be extra secure, click No and add a passphrase to the key, otherwise click Yes to proceed.

Now just choose the directory that you want to store your new private PPK key in, give it a name and click Save. For ease, I’d keep it with your original PEM key and consider naming it exactly the same, too (the file extensions will differentiate them from each other).

Now that we have our PPK key, feel free to close PuTTYgen.

Step 2: Configure PuTTY

With our private key converted into PPK format, we now have a key (ha!) component that PuTTY needs to connect to the AWS server via SSH. Let’s configure PuTTY now.

Create a New Profile & Save the IP Address

Launch PuTTY and you’ll be presented with the Session screen. This is where you can start basic connections instantly, as well as save and load ‘profiles’ to connect to different servers quickly and easily without needing to configure the connection each time.

As we need the private key to connect to the server (instead of simply using a password), we can’t really connect instantly without configuring a couple of options first. It will also save us time in future if we set up our profile now, so let’s spend 60 seconds setting it up and saving it.

To start with, enter the public IP address of your AWS EC2 instance into the Host Name (or IP address) field. Remember that you can get this from AWS EC2 when you select your instance from the Instances view (see screenshot below).

Then, back in PuTTY, give your profile a name in the Saves Sessions field and click Save. This will add it to the list of saved profiles, so whenever you load this profile by selecting it and clicking Load, it will automatically bring up the IP address you just entered. We’re going to configure a couple of other bits now and return here to make sure we save it again.

The next thing we’ll add is the username that we’ll be logging into the server with.

Add Username

This step is a quick one. You don’t have to do it, but it will save you having to remember the username and may save you a couple of seconds each time you want to login to your server via SSH.

To add your username, expand the Connections node on the left if it isn’t already, and then select the Data node.

At the top, you should see an option called Auto-login username. It’s fairly self-explanatory, but this will be the username that PuTTY uses automatically when it tries to connect to your AWS EC2 server via SSH.

In this field you’ll want to type bitnami. This is the default user that Bitnami creates for it’s AWS AMIs with all relevant permissions and security considered. Don’t worry, you can still do practically anything with the permissions this user has.

The final thing we’ll add is our PPK key.

Select PPK Key

Start by expanding the SSH node under Connection, then click on to (but no need to expand) the Auth node. This displays authentication options that PuTTY can use when it connects with a server.

At the bottom you should see Private key file for authentication with a blank field below it. Click Browse, highlight your PPK key from the file explorer and click Open (but don’t click Open in PuTTY yet). Now PuTTY will use this specific PPK key when it starts talking to your AWS EC2 server.

Now, return to the Session screen and click Save to save your updated profile.

Step 3: Connect via SSH

With everything saved, there’s just one thing left to do; connect!

Assuming that you’ve now saved your profile and you’re on the Session screen, just click the Open button.

You may have an alert pop up as this is the first time you’re connecting to this server, so click Yes to proceed.

If you followed every step above and there are no unforeseen circumstances, the PuTTY terminal should launch and you’ll see something like the screenshot below.

Congratulations! You’ve successfully connected to your AWS EC2 instance.

As always, let me know how you get on in the comments below.

Leave a Reply

Your email address will not be published.