How to connect to a Windows EC2 instance from macOS


I normally use Linux for the majority of my labs, but this time I had to prepare an installation for a customer on Windows Server. For that, I’ve created an EC2 instance in AWS with a Windows Server image.


When we’ve got an EC2 instance in AWS, the way we connect to that VM depends on the Operating System we installed on it. Typically I used Linux for the majority of my labs, so I just open my terminal and ssh into that box. But this week, I’m working on a PoC for a customer with Windows. In this post, I wanted to share how we do that with a Windows Server. Here are the steps I followed:

Prerequisites

Secure the traffic on port 3389

  • In a Windows system we’ll use the Remote Desktop Protocol (RDP) to connect to our instance. The RDP protocol uses the port 3389. So, the first thing we need to do is to allow incoming traffic to that port in the Security Group controlling our EC2 instance. 
  • Connections to this port should not be open to everyone. This is a private connection that only the Admins of the Windows system should be allowed to do. So, the recommendation is that you edit the inbound rules of the Security Group of your EC2 to allow incoming connections on port 3389 ONLY to the private IPs or range of IPs of your Windows Admins.
  • Allow port 3389 for RDP in the EC2 instance

Get the Remote Desktop app

  • If you are connecting from a Windows laptop you already have the remote desktop app to connect to the Windows server (this uses port 3389)
  • If you, like me, use a macOS, then we need to download the RDP app from the App Store. Search for remote desktop on your App Store and download the Windows App.

Connect to our EC2 instance

Once our RDP client has been downloaded, open the app and, from the top-right corner, click on Add PC.


Next, provide the hostname of your EC2 instance (you can copy it from the Public DNS name of the EC2 instance), and click Add


Once create, it will prompt you for the credentials to access Windows. For the credentials, head over to the AWS Management Console > EC2 and click on the EC2 instance with Windows. Click on Connect and then, on the next window, select the RDP client tab. You’ll see that the username is Administrator. The password is not directly provided, it’s encrypted. To decrypt it, click on Get password


To decrypt the password we will need to provide the private key we generated when we created the EC2 instance. Click on Upload private key file and provide the key file. Nex, click Decrypt password


You’ll see that now the password is available for you to copy it:


Get back to our RDP client and provide the username and password we’ve just got:


Click Continue and... voila! Your RDP session with your Windows Server on EC2 is ready for you.

Previous Post Next Post