Aang Wiadi 11-Feb-2025 Linux Server,Ubuntu, Security

Generating SSH Key Pairs with PuTTY to Connect to a VPS

 Generating SSH Key Pairs with PuTTY to Connect to a VPS

Step 1: Download and Install PuTTY & PuTTYgen

  1. Download PuTTY from the official site:
  2. ???? https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
  3. Install PuTTY and PuTTYgen (included in the installation).

Step 2: Generate SSH Key Pair Using PuTTYgen

  1. Open PuTTYgen.
  2. Under "Parameters," select:
  3. RSA (Recommended) or EdDSA (Ed25519) for better security.
  4. Set key size:
  5. 2048-bit (Minimum) or 4096-bit (More Secure).
  6. Click Generate and move the mouse over the blank area to generate randomness.
  7. When the key is generated:
  8. Save the private key (.ppk file).
  9. 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

  1. Use PuTTY or another SSH client to connect to your VPS using a password.
  2. 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

  1. 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

  1. Open PuTTY.
  2. In the "Host Name (or IP address)" field, enter your VPS IP.
  3. Go to Connection → SSH → Auth and:
  4. Click Browse.
  5. Select your private key (.ppk file).
  6. Click Open to start the SSH session.


Step 5: Disable Password Authentication (Optional, for Security)

  1. 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

  1. Permission denied?
  2. Ensure .ssh/authorized_keys exists and has correct permissions (chmod 600).
  3. Wrong key format?
  4. Convert .ppk to OpenSSH format if needed (Export OpenSSH Key in PuTTYgen).
  5. SSH service not running?
  6. Check SSH status:


sudo systemctl status ssh


Let me know if you need further help! ????