Ravindra BagaleCourses & study guides

4. Amazon EC2: Launch and Connect to Your Linux Server

4.5 SSH from Windows: PowerShell, PuTTY and MobaXterm

Class madhe bahutek students Windows laptop vaprtat, mhanun teen paryay baghuya. Konta pan ek neet shika – PowerShell sarvaat soppa aahe karan Windows 10/11 madhe OpenSSH already aahe.

From Windows — option 1: built-in OpenSSH (Windows 10/11)

Open PowerShell and fix the key permissions (Windows equivalent of chmod 400):

cd $env:USERPROFILE\Downloads
icacls.exe mykey.pem /reset
icacls.exe mykey.pem /grant:r "$($env:USERNAME):(R)"
icacls.exe mykey.pem /inheritance:r
ssh -i .\mykey.pem ec2-user@<PUBLIC_IP>

From Windows — option 2: PuTTY

  1. Install PuTTY (includes PuTTYgen).
  2. If you downloaded a .pem: open PuTTYgen → Load → choose All files → select mykey.pem → Save private key as mykey.ppk.
  3. Open PuTTY → Session → Host Name: ec2-user@<PUBLIC_IP> (or ubuntu@...), Port 22.
  4. Connection → SSH → Auth → Credentials → Private key file for authentication → browse to mykey.ppk.
  5. Back to Session, type a name under Saved Sessions → Save → Open → Accept the host key.

From Windows — option 3: MobaXterm

  1. Install MobaXterm (Home edition is free).
  2. Session → SSH → Remote host: <PUBLIC_IP>, tick Specify username: ec2-user / ubuntu.
  3. Advanced SSH settings → tick Use private key → select mykey.pem (MobaXterm accepts .pem directly).
  4. OK. The left panel gives a graphical SFTP browser — drag-and-drop files to upload.

Other connection options

  • EC2 Instance Connect (browser-based): select instance → Connect → EC2 Instance Connect tab → Connect. Works out-of-the-box on Amazon Linux and Ubuntu AMIs when port 22 is open to the EC2 Instance Connect IP range for your region (or to 0.0.0.0/0).
  • Session Manager (AWS Systems Manager): no port 22 needed at all; requires the SSM agent and an IAM role (AmazonSSMManagedInstanceCore). Recommended in companies.

Why this matters for security

Session Manager removes the need to open port 22 at all – no SSH port means no SSH brute force. Many companies use it for exactly this reason, together with IAM-based access and full session logging.

Ravindra Bagale's Tip

PuTTY madhe .pem direct chalat nahi – aadhi PuTTYgen ne .ppk banva. Khup students ithe "Server refused our key" error la ghabartat. Aani Windows PowerShell madhe icacls che teen commands visru naka – te Windows cha chmod 400 aahe.

Practice task

Connect to your instance once with PowerShell and once with PuTTY or MobaXterm. In MobaXterm, upload a small file using the SFTP side panel.