Articles on: Public Articles

Setting up SSH Keys using PuTTY on Windows

PuTTY is the most typical and effective client for establishing an SSH connection to a server on Windows systems. The setup process requires two tools: PuTTY (the client) and PuTTYgen (the key generator).

1.  Download and Initial Configuration


A. Download PuTTY and PuTTYgen

You should download both tools from the official source. (Insert direct download links for the Windows x86 files here).


B. Create the Connection Profile (PuTTY)


Open the PuTTY program and configure the server session:

  1. Session: Enter the Server IP address or Domain Name in the Host Name field.
  2. Port: The default port is 22. If your server uses a non-standard port (e.g., 2222), change it accordingly.
  3. Connection > Data: Specify the username you intend to connect with (e.g., cpanel_username) in the Auto-login username field.
  4. Save Session: Go back to the Session screen, type an identifying name for your profile (like your domain name), and click Save.


2.  Generate the Private and Public Keys (PuTTYgen)


Use the PuTTYgen program to generate the key pair:

  1. Settings: Ensure SSH-2 RSA is selected as the key type and the key size is at least 2048 bits (4096 is preferred).
  2. Generation: Click the Generate button and move your mouse randomly within the blank area to aid in key randomness.
  3. Passphrase: We strongly recommend setting a strong passphrase to protect your Private Key. If you require a truly "passwordless login," leave this field blank.
  4. Save:
    • Click Save Public Key (save as public-key.pub).
    • Click Save Private Key (save as private-key.ppk).
    • Crucial: Save both files in a secure location on your machine.


3. Upload the Public Key to the Server


To add the key to the server's list of authorized keys:

  1. Copy the Key: In the PuTTYgen window, copy the entire text within the box labeled "Public key for pasting into OpenSSH authorized_keys file".
  2. Connect to Server: Open your saved PuTTY session and click Open. (You might be prompted for the current password).
  3. Create Directories and Permissions: Once inside the terminal, execute the following commands:

Bash

 ```

mkdir ~/.ssh

chmod 700 ~/.ssh

nano ~/.ssh/authorized_keys


4. **Paste the Key:** **Right-click** inside the PuTTY window to paste the copied key.
5. **Key Formatting (Crucial):** The entire key must be on **a single line** without extra line breaks. If it pasted onto multiple lines, go to the beginning of the second and subsequent lines and press `Backspace` to merge them.
6. **Save and Exit:** Press **CTRL+X**, then **Y** (to save), then **Enter**.
7. **Confirm Permissions:** Return to the terminal and set the permissions:
Bash
 

chmod 600 ~/.ssh/authorized_keys


### 4.  Configure PuTTY to Use the Key

Close the old PuTTY window and open PuTTY again:
1. **Load Profile:** From the `Session` screen, select your saved profile and click **Load**.
2. **Point to Private Key:** On the left menu, navigate to **Connection > SSH > Auth**.
3. Click the **Browse** button and locate the Private Key (`.ppk`) you saved in step two.
4. **Final Save:** Return to the `Session` screen and click **Save** one last time to store the new configuration.

### 5.  Confirmation
Click **Open** to connect. PuTTY should instantly log you into the server (or only prompt for your Private Key passphrase), bypassing the need for a password.

Updated on: 04/12/2025

Was this article helpful?

Share your feedback

Cancel

Thank you!