If you've been typing passwords every time you SSH into your CentOS server, there's a better way. SSH key authentication not only saves time but also adds an extra layer of security to your remote connections. Let me walk you through setting this up with PuTTY in a few straightforward steps.
Think about it this way: passwords can be guessed, stolen, or intercepted. SSH keys work differently—they use a pair of cryptographic keys that are nearly impossible to crack. Plus, once you set this up, you'll connect to your server with just a click. No more memorizing or typing complex passwords every single time.
For anyone managing multiple servers or connecting frequently throughout the day, this setup becomes a real productivity boost. The initial configuration takes maybe 10 minutes, but you'll save that time back within a week.
First, you'll need PuTTYgen, which is the key generator tool that comes with PuTTY. If you don't have it yet, grab the latest version from the official PuTTY website.
Once you have PuTTYgen running, here's what to do:
Launch PuTTYgen and you'll see a simple interface with a big "Generate" button. Click it, then move your mouse randomly around the blank area. This movement creates the randomness needed to generate a secure key—it's oddly satisfying to watch the progress bar fill up as you wiggle your cursor around.
When the generation finishes, you'll see your public key displayed in a text box. Don't close this window yet—you'll need that key in just a moment.
Save your private key by clicking the "Save private key" button. The tool will ask if you want to protect it with a passphrase. For most personal use cases, you can skip the passphrase and click "Yes" to save without one. Just remember: whoever has access to this file can access your server, so store it somewhere safe.
👉 Looking for reliable server hosting with robust SSH support and DDoS protection?
Now switch over to your CentOS server. You'll need to log in the old-fashioned way one last time using your password.
Once you're connected, create the SSH directory and authorized keys file if they don't exist already:
Create the .ssh directory in your home folder if it's not there. Most systems already have this, but it doesn't hurt to check. The command mkdir -p ~/.ssh will create it only if needed.
Edit the authorized_keys file by running vim ~/.ssh/authorized_keys. If you're not comfortable with vim, you can use nano instead—just swap out the command.
Now go back to that PuTTYgen window where your public key is still displayed. Copy everything in the box labeled "Public key for pasting into OpenSSH authorized_keys file." Head back to your server terminal and paste this entire key into the authorized_keys file. Save and exit.
One important detail: make sure the permissions are correct. Run chmod 700 ~/.ssh and chmod 600 ~/.ssh/authorized_keys. SSH is picky about file permissions for security reasons, and if these aren't set right, key authentication won't work.
Back on your Windows machine, open PuTTY and let's configure it to use your new key:
Session settings: In the main PuTTY window, enter your server's IP address or hostname in the "Host Name" field.
Auto-login username: Navigate to Connection → Data in the left sidebar. Fill in your username in the "Auto-login username" field. This saves you from typing it every time.
Point to your private key: Go to Connection → SSH → Auth. Click "Browse" next to "Private key file for authentication" and select the private key file you saved earlier from PuTTYgen.
Save your session: Jump back to the Session category at the top of the sidebar. Give your session a memorable name in the "Saved Sessions" field and click Save. From now on, you can just double-click this saved session to connect instantly.
👉 Need a server that handles high-traffic SSH connections smoothly?
Hit "Open" and watch the magic happen. If everything is configured correctly, you'll connect to your CentOS server without being prompted for a password. It should drop you straight into your command prompt.
If something goes wrong, don't panic. The most common issues are incorrect file permissions on the server side or pointing PuTTY to the wrong key file. Double-check both of those first.
Keep that private key file backed up somewhere secure. If your hard drive dies and you lose it, you'll need to go through this setup process again—or fall back to password authentication.
Consider setting up key-based authentication for all your servers at once. Once you get the hang of it, the process takes just a couple of minutes per server, and the convenience compounds quickly.
For production environments or shared systems, you might want to add that passphrase protection to your private key after all. It's a small extra step when connecting, but it means someone who gets access to your key file still can't use it without the passphrase.
That's it—you're now set up for faster, more secure SSH connections. Your fingers will thank you for not having to type that password dozens of times a day.