Configure SSH in PuTTY
Complete guide to setting up and configuring SSH connections
Introduction: Connecting via SSH in PuTTY
SSH (Secure Shell) is the standard protocol for secure remote server access. PuTTY makes it easy to establish SSH connections to Linux, Unix, and other SSH-enabled systems from Windows.
This guide covers everything from basic SSH configuration to advanced authentication methods and troubleshooting common connection issues.
Basic Configuration Steps
Step 1: Launch PuTTY
- Double-click
putty.exe
to open the PuTTY Configuration window - You'll see the Session category selected by default
- This is where you'll configure your basic connection settings
Step 2: Enter Hostname or IP Address
In the "Host Name (or IP address)" field, enter one of:
- Domain name:
example.com
- Subdomain:
server.example.com
- IPv4 address:
192.168.1.100
- IPv6 address:
2001:db8::1
Note: Don't include ssh://
or http://
prefixes – just the hostname or IP address.
Step 3: Set Port and Connection Type
Port Configuration:
- Default SSH port:
22
- Custom port: If your server uses a non-standard port (e.g., 2222), enter it here
- The port number is displayed to the right of the hostname field
Connection Type:
- Select "SSH" from the connection type options
- Other options: Raw, Telnet, Rlogin, Serial (not commonly used)
- SSH is the most secure option and should be used for remote connections
Step 4: Configure Username (Optional but Recommended)
To avoid typing your username each time:
- In the left panel, navigate to Connection → Data
- Find the "Auto-login username" field
- Enter your SSH username (e.g.,
root
,admin
,ubuntu
) - PuTTY will automatically use this username when connecting
Step 5: Save Your Session
Save your configuration for easy access:
- Return to the Session category (top of left panel)
- In the "Saved Sessions" field, enter a descriptive name:
Production Web Server
Dev Database - MySQL
Client XYZ - Main
- Click the "Save" button
- Your session now appears in the list below
Pro Tip: Double-clicking a saved session will immediately connect using those settings!
Step 6: Open Connection
- Click the "Open" button at the bottom of the window
- If this is your first connection to this server, you'll see a security alert
- Click "Accept" to trust the server's host key
- A terminal window opens
- Enter your password when prompted (if using password authentication)
Key-Based Authentication
SSH keys provide stronger security and convenience compared to passwords.
Prerequisites
- You've generated an SSH key pair using PuTTYgen
- Your public key is installed on the remote server
- You have the private key file (.ppk format)
Configuring Key Authentication
- Open your saved session or create a new one
- In the left panel, navigate to:
Connection → SSH → Auth → Credentials - Click "Browse" next to "Private key file for authentication"
- Select your
.ppk
private key file - Return to Session and click "Save" to update
- Click "Open" to connect
- Enter your key passphrase if you set one
Tip: Use Pageant (PuTTY's SSH agent) to load your key once per session, avoiding repeated passphrase prompts.
Advanced SSH Configuration
Keepalive Settings
Prevent disconnections due to inactivity:
- Navigate to Connection
- Set "Seconds between keepalives" to 60
- Enable "Enable TCP keepalives (SO_KEEPALIVE option)"
- This sends periodic packets to keep the connection alive
SSH Protocol Version
- Navigate to Connection → SSH
- Under "Protocol options", select SSH protocol version 2 only
- SSH-2 is more secure and should always be used
- SSH-1 is obsolete and vulnerable
Compression
For slow connections, enable compression:
- Navigate to Connection → SSH
- Enable "Enable compression"
- Useful for high-latency or low-bandwidth connections
- May slightly increase CPU usage
Port Forwarding (SSH Tunneling)
Create secure tunnels to access services through SSH:
Local Port Forwarding Example:
- Navigate to Connection → SSH → Tunnels
- Source port:
3307
(local port on your machine) - Destination:
localhost:3306
(MySQL on remote server) - Click "Add"
- When connected,
localhost:3307
on your machine forwards to MySQL on the server
X11 Forwarding (GUI Applications)
Run graphical applications remotely:
- Navigate to Connection → SSH → X11
- Enable "Enable X11 forwarding"
- Requires an X server on Windows (e.g., Xming, VcXsrv)
- GUI apps will display on your Windows desktop
Troubleshooting Connection Failures
Error: "Network error: Connection refused"
Possible causes:
- SSH service not running on the server
- Firewall blocking port 22
- Wrong port number
- Server is down
Solutions:
- Verify the server is online:
ping hostname
- Check if SSH service is running on the server
- Verify the correct port number
- Check firewall rules (both client and server)
Error: "Network error: Connection timed out"
Possible causes:
- Network connectivity issues
- Firewall blocking connection
- Incorrect hostname/IP
- Server not responding
Solutions:
- Verify internet connection
- Check if hostname resolves:
nslookup hostname
- Try alternative network (mobile hotspot, VPN)
- Contact server administrator
Error: "Server refused our key"
Possible causes:
- Public key not added to server's
authorized_keys
- Wrong private key selected
- File permissions incorrect on server
- Server doesn't allow public key authentication
Solutions:
- Verify public key is in
~/.ssh/authorized_keys
on server - Check file permissions:
~/.ssh/
should be 700,authorized_keys
should be 600 - Try password authentication to diagnose
- Check server's
/etc/ssh/sshd_config
forPubkeyAuthentication yes
Error: "Access denied"
Possible causes:
- Wrong username
- Wrong password
- Account locked or disabled
- IP address blocked by fail2ban or similar
Solutions:
- Double-check username and password
- Verify account is active on the server
- Contact server administrator to check for IP blocks
- Wait 10-15 minutes if locked by brute-force protection
Error: "Host key verification failed"
Possible causes:
- Server's host key has changed (reinstalled OS, new server)
- Man-in-the-middle attack (rare)
- Cached old host key in PuTTY
Solutions:
- If you know the server was rebuilt, this is expected
- In PuTTY, click "Update" to accept the new key
- Or manually delete old key from Windows Registry:
HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\SshHostKeys
- If unexpected, contact your server administrator before proceeding
Session Management Best Practices
Naming Conventions
- Use descriptive, consistent names
- Include environment:
Prod-WebServer-01
,Dev-Database
- Include client/project:
ClientA-Main
- Use prefixes for grouping:
AWS-
,Azure-
,Colo-
Session Backup
Export your PuTTY sessions for backup:
- Open Registry Editor (
regedit
) - Navigate to:
HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions
- Right-click "Sessions" → Export
- Save as
putty-sessions-backup.reg
- To restore: Double-click the .reg file
Security Recommendations
- ✅ Always use SSH (never Telnet) for remote connections
- ✅ Prefer key-based authentication over passwords
- ✅ Use strong passphrases for private keys
- ✅ Keep PuTTY updated to the latest version
- ✅ Verify host keys on first connection
- ✅ Use non-standard SSH ports when possible
- ✅ Enable keepalives to maintain connections
- ❌ Never share private keys
- ❌ Don't ignore host key warnings
Quick Reference
Setting | Location | Common Value |
---|---|---|
Hostname | Session | example.com |
Port | Session | 22 |
Username | Connection → Data | root, ubuntu, admin |
Private Key | Connection → SSH → Auth → Credentials | *.ppk file |
Keepalive | Connection | 60 seconds |
Compression | Connection → SSH | Enabled for slow links |