Generating SSH Key Pairs with PuTTY to Connect to a VPS

Step 1: Download and Install PuTTY & PuTTYgen
- Download PuTTY from the official site:
- ???? https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
- Install PuTTY and PuTTYgen (included in the installation).
Step 2: Generate SSH Key Pair Using PuTTYgen
- Open PuTTYgen.
- Under "Parameters," select:
- RSA (Recommended) or EdDSA (Ed25519) for better security.
- Set key size:
- 2048-bit (Minimum) or 4096-bit (More Secure).
- Click Generate and move the mouse over the blank area to generate randomness.
- When the key is generated:
- Save the private key (
.ppk
file). - Copy the public key from the top of the PuTTYgen window.
Step 3: Upload the Public Key to Your VPS
Option 1: If You Have SSH Password Access
- Use PuTTY or another SSH client to connect to your VPS using a password.
- Run the following command:
mkdir -p ~/.ssh && nano ~/.ssh/authorized_keys
Paste the public key from PuTTYgen.
Save and exit (CTRL + X
, then Y
and Enter
).
Set proper permissions:
chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh
Option 2: If You Have a Control Panel
- Some VPS providers (like AWS, DigitalOcean, etc.) allow you to add SSH keys through their web interface.
Step 4: Configure PuTTY for SSH Key Authentication
- Open PuTTY.
- In the "Host Name (or IP address)" field, enter your VPS IP.
- Go to Connection → SSH → Auth and:
- Click Browse.
- Select your private key (
.ppk
file). - Click Open to start the SSH session.
Step 5: Disable Password Authentication (Optional, for Security)
- Edit the SSH configuration:
sudo nano /etc/ssh/sshd_config
2. Find and update:
PasswordAuthentication no
sudo systemctl restart ssh
sudo systemctl restart ssh
Troubleshooting
- Permission denied?
- Ensure
.ssh/authorized_keys
exists and has correct permissions (chmod 600
). - Wrong key format?
- Convert
.ppk
to OpenSSH format if needed (Export OpenSSH Key
in PuTTYgen). - SSH service not running?
- Check SSH status:
sudo systemctl status ssh
Let me know if you need further help! ????