Can we SSH to Windows EC2 instance in AWS?

Viewed 5235

I am new to AWS and I have created a new Windows EC2 instance. I see ways to SSH to different instances like Amazon Linux, Ubuntu using PuTTY. But not for Windows instance. Can we not connect to Windows instance using PuTTY? Any help would be appreciated. Thanks.

4 Answers

You can SSH to Linux and Mac instance on AWS. You can use Remote Desktop (RDP) to access Windows Instances.

Suppose you wanted to SSH into a Windows instance, then you would have to install OpenSSH. Which would still require access to the Windows instance.

AWS offers a few ways to access your Windows instance, one of them is AWS Systems Manager Session Manager (SSM). You would need to enable RDP through SSM. You can find out how to do this via this workshop. Alternatively configure SSM to run powershell commands against the instance Note the instance must have a role that has IAM access to SSM. If the instance is in a private VPC it would require access to SSM via endpoints.

If your instances is in a public subnet, and has a public IP address then you can easily connect to your Windows instance using RDP. Note just like your EC2 Instances running Linux, the security group must allow access. In this case it must be to RDP (3389) and not SSH (Port 22). You can read more about the prerequisites here.

When you created your Windows EC2 instance, you were asked to create a key. You can use this key to get the Windows password, assuming you used an AWS AMI.

Access your password

Follow these steps (From the documentation here):

  • Open the Amazon EC2 console, and then choose Instances.

  • Select the check box for the instance, and then expand the Actions dropdown list. If you're using the old console, then choose Get Windows Password. If you're using the new console, choose Security, and then choose Get Windows Password. Note: It can take a few minutes for this option to be available after you first launch a new instance.

  • Choose Browse, select your key pair file, and then choose Open.

    -or-

  • Paste the contents of your key pair into the text box. Choose Decrypt Password.

Connect to the Instance

On the password screen, Choose Download remote desktop file. Your browser prompts you to either open or save the RDP shortcut file. Select the option to save the file. When you have finished downloading the file, choose Cancel to return to the Instances page.

  • Navigate to your downloads directory and open the RDP shortcut file.

  • You might get a warning that the publisher of the remote connection is unknown. Choose Connect to continue to connect to your instance.

  • The administrator account is chosen by default. Copy and paste the password that you saved previously.

  • You can also use EC2 Serial Console to access an EC2 instance running Windows, this is great to debug boot issues.

  • Due to the nature of self-signed certificates, you might get a warning that the security certificate could not be authenticated. Use the following steps to verify the identity of the remote computer, or simply choose Yes (Windows) or Continue (Mac OS X) if you trust the certificate.

For more details on how to connect, visit this site.

Can we SSH to Windows EC2 instance in AWS? - NO.

Windows EC2 you can connect using RDP( Remote Desktop ). You can download .rdp file from AWS console navigating through select instance -> connect -> RDP

SSH connection is for Linux based EC2 machine.

You can connect to your Windows EC2 via AWS Session Manager. It let you to manage your instance from browser based shell. Like SSH, you can manage your EC2 from the shell provided by the SSM. You can execute power shell commands from the console.

To use SSM, first you need to install ssm agent in instance and grant EC2 with required SSM policies in IAM role.

I believe SSM agent is by default installed in Windows EC2 instances. Also AWS providing one role named AmazonSSMRoleForInstancesQuickSetup for EC2. You can use the same or utilise the policies inside this role.

To connect: Select the instance and in the Connect option select Session manager

PuTTy is not the tool to use typically for Windows machines. While I'm sure it is possible to setup SSH access for Windows machines, the methods below are more typical and easier to setup.

If you have a keypair associated to your EC2 instance, you can use the AWS console to show you the username and password needed to use Windows Remote Desktop to access your machine by giving it your pem file. This will also require you to enable inbound RDP access (a different port than SSH) in your security group.

If you just want PowerShell access and you are using an instance with with the SSM agent installed (e.g. Amazon Linux AMIs) and a role with the required SSM permissions, you can use Session Manager to connect. This does not need a keypair or direct network access to your machine so this is a more secure method but requires a bit more setup.

Both techniques are described is more detail in the reference below.

References:

Related