How to Connect To Linux (CentOs 7) Using SSH Keys (Password free authentication) from Windows

Published: December 1, 2025 (Updated: Dec 1, 2025)

Enjoying this content? Subscribe to the Channel!

Ditch the Password! Secure CentOS 7 Login from Windows using SSH Keys (PuTTY Tutorial)


Welcome back to Darren’s Tech Tutorials!

If you are tired of typing in a long, complicated password every time you connect to your CentOS server, then this guide is for you. We’re going to walk through the process of setting up SSH key-based authentication between your Windows machine and a CentOS 7 server using the free and popular tool, PuTTY.

Using SSH keys is not just about convenience—it dramatically increases your security. Once configured, you can log in instantly without a password, relying instead on a unique, encrypted key pair. Let’s get started!


Step 1: Download PuTTY and PuTTYgen

The first step is ensuring you have the necessary software on your Windows machine. PuTTY is the standard SSH client, and it comes bundled with PuTTYgen, the utility we use to create our secure key pair.

  1. Open your browser and navigate to the official source: www.putty.org.
  2. Download the appropriate installer (e.g., the 64-bit version).
  3. Install the software using the default settings.

Pro Tip: Before moving on, it’s always a good idea to open PuTTY and confirm you can log into your server normally using your password. Enter your server’s IP address (e.g., 192.168.1.133), set the Auto-login username (like ‘Darren’), and save the session. This verifies your network connection is working as expected.

Step 2: Generate Your Public/Private Key Pair

Now we need to create the unique keys that will allow you to authenticate securely.

  1. Open PuTTYgen (you can find it in your Windows Start menu).
  2. Ensure the key type selected is RSA (this is the default and recommended setting).
  3. Click the Generate button.
  4. To create cryptographic randomness, move your mouse randomly over the blank grey area beneath the progress bar until the key generation is complete.
  5. Once the key is generated, you will see a large block of text labeled “Public key for pasting into OpenSSH authorized_keys file.”

Save Your Keys

We need to save two files—the public key (which goes on the server) and the private key (which stays securely on your Windows machine). We recommend creating a folder (e.g., “SSH Keys”) on your desktop for easy management.

  1. Save the Private Key: Click Save private key. PuTTY will warn you about saving it without a passphrase. If you want a truly passwordless login experience, click Yes to bypass the passphrase. Save it as my_private_key.ppk.
  2. Save the Public Key: Click Save public key. Save it as my_public_key.pub.

Important: The key you need for the server configuration is the text shown in the large Public Key box, not the file you just saved. Copy this entire block of text now—you will paste it onto the server in the next step.

Step 3: Configure CentOS 7 to Accept the Public Key

Now we move over to the server side. We must create a secure directory for the keys and then paste our public key into the server’s authorized keys file.

  1. Open your standard PuTTY session, connect to your server, and log in using your password one last time.
  2. Execute the following commands sequentially. These commands create the required .ssh directory, set strict permissions, and place your key in the authorization file.

1. Create the .ssh directory and set permissions (Mode 700)

We use mkdir to create the directory and chmod 700 to ensure only the user can read, write, and execute files within it (critical for security).

sudo mkdir ~/.ssh
sudo chmod 700 ~/.ssh

2. Add the Public Key to the authorized_keys file

We use the vi editor to create and edit the authorized_keys file.

sudo vi ~/.ssh/authorized_keys

When the vi editor opens:

  • Press I to enter Insert mode.
  • Right-click your mouse to paste the entire public key text you copied from PuTTYgen earlier.
  • Press ESC to exit Insert mode.
  • Type :wq (write quit) and hit Enter to save and close the file.

3. Set Final File Ownership and Permissions

We must ensure the directory and the new file are owned by your user and that the key file itself has very restricted permissions (Mode 600).

NOTE: Replace YourUserName with your actual Linux user account name (e.g., Darren).

sudo chown YourUserName:YourUserName ~/.ssh -R
sudo chmod 600 ~/.ssh/authorized_keys

To ensure the server is ready to use the new configuration, restart the SSH daemon:

sudo service sshd restart

Type exit to close the terminal session. The server configuration is now complete!

Step 4: Update Your PuTTY Session for Key Authentication

The final step is to tell PuTTY to use your private key file instead of asking for a password.

  1. Open PuTTY and load your previously saved server session (e.g., “My Server”).
  2. In the left-hand menu, navigate to Connection > SSH > Auth.
  3. Click the Browse button under “Private key file for authentication.”
  4. Select the private key file you saved earlier (my_private_key.ppk).
  5. Go back to the Session category at the very top of the menu.
  6. Click Save to update your session settings.

You are now ready to test!

Click Open. You should see the terminal connect instantly, authenticating with “publickey,” and dropping you straight into your command prompt without prompting you for a password! Success!


Conclusion: Embrace Secure, Passwordless Login

Congratulations! You have successfully implemented a far more secure and convenient method for accessing your CentOS server. SSH keys are the industry standard for good reason—they provide strong encryption while saving you time and effort.

Now that you’ve got this process nailed down, you can set up unique keys for all your systems, ensuring your infrastructure is both efficient and robust.

If you enjoyed this detailed tutorial, be sure to Like this post and Subscribe to Darren’s Tech Tutorials for more clear, step-by-step guides. Got questions or running into trouble? Leave a comment below, and I’ll certainly do my best to help you out!

Thanks for reading!