PuTTY saved sessions versus command-line flags for repeatable SSH access
Choose between PuTTY Registry sessions and command-line flags for repeatable Windows SSH access, including port forwarding and public-key authentication.
10 Sept 2025, 08:03 UTC

The problem: repeated manual SSH setup on Windows
Every time you open PuTTY on Windows, you retype the hostname, port, username, and SSH options. If you also maintain local or remote port forwarding, you re-enter tunnel mappings too. That repetition is slow and easy to mistype, especially when you connect to the same Linux servers, network devices, or internal services daily.
The practical takeaway is to save a session in PuTTY's Windows Registry store for hosts you use regularly, then apply command-line flags only when you need to override a stored value. PuTTY keeps each saved session under `HKCU\Software\SimonTatham\PuTTY\Sessions`, preserving host, port, protocol, username, and SSH settings. Launch it with `putty.exe -load session-name`.
Decision and constraints
Decide whether to standardize on saved sessions, ad-hoc command-line invocation, or a hybrid where a saved session supplies defaults and flags override specific values.
Constraints to verify first:
- The client is Windows and PuTTY is installed.
- The target host accepts SSH-2. Current PuTTY releases no longer support SSH-1.
- You have standard user access to `HKCU`; administrator rights are not required to save or launch sessions.
- Private keys must be PuTTY `.ppk` files. OpenSSH keys require conversion with PuTTYgen before PuTTY can use them.
Supported options compared
| Approach | Where settings live | Best for | Typical command | Drawback |
|---|---|---|---|---|
| Saved Registry session | `HKCU\Software\SimonTatham\PuTTY\Sessions` | Daily connections to the same hosts | `putty.exe -load Web-01` | Tied to one Windows user profile; passwords are not stored by default |
| Ad-hoc command line | Command shell only | One-off or scripted connections | `putty.exe -l admin -P 2222 10.0.0.9` | Flags must be repeated every time; easy to mistype |
| Saved session plus command-line overrides | Registry plus shell | Same host, different port, user, or tunnel | `putty.exe -load Web-01 -L 8080:localhost:80 -l deploy` | Option order matters; flags after `-load` override stored values |
Trade-offs
Saved sessions reduce repetitive typing and make tunnel definitions reusable, but the data stays in the current Windows user profile. Moving it to another machine or user requires exporting a `.reg` file. Command-line invocation is portable across shells but does not persist anything, so documentation or scripts must carry the full flag set. The hybrid approach gives you persistence with flexibility, provided you remember that options placed after `-load` take precedence over the saved session.
Implementation: save and launch a repeatable session
- Open PuTTY. In the Session panel, enter the host name, port, and confirm SSH is selected as the protocol.
- Optionally, under Connection > Data, enter an auto-login username. Do not store a password; PuTTY does not save login passwords in sessions by default.
- Return to the Session panel, type a name such as `Web-01` in the Saved Sessions box, and click Save.
- Close PuTTY. Open Command Prompt or PowerShell and run:
putty.exe -load Web-01
If the session name contains spaces, enclose it in double quotes. No administrator permission is needed because the session is written to `HKCU`.
Add port forwarding to a saved session
You can store forwarding in the session or add it at launch. To forward a local port to a database on the remote host, run:
putty.exe -load App-01 -L 3306:localhost:3306
The `-L` flag appears after `-load`, so it overrides or supplements the stored session. This forwards local port 3306 to port 3306 on the remote host through the SSH tunnel.
Verify the listener with PowerShell:
Get-NetTCPConnection -LocalPort 3306
Expected result: a local connection in Listen state. If nothing appears, another process may already hold the port, or the tunnel did not establish. Check the PuTTY event log for connection errors.
Use public-key authentication instead of passwords
If your OpenSSH private key is not already in PuTTY format, open PuTTYgen, load the OpenSSH key, and save it as a `.ppk` file. In PuTTY, go to Connection > SSH > Auth > Private key file, browse to the `.ppk`, then return to Session and save the session. Connect to the host. A successful key authentication means no password prompt appears. If PuTTY still asks for a password, the key was rejected, the wrong `.ppk` was selected, or the server does not accept the corresponding public key.
Validate what you configured
- List saved sessions in Command Prompt or PowerShell:
Expected output includes your session name. Standard user permissions are sufficient because this reads `HKCU`.reg query "HKCU\Software\SimonTatham\PuTTY\Sessions" - Open PuTTY, load the session, and confirm the Session panel shows the stored hostname, port, and SSH protocol before connecting.
- Test a forwarded port by launching with `-L 8080:localhost:80`, then run `Get-NetTCPConnection -LocalPort 8080` in PowerShell or `netstat -ano` in Command Prompt.
- Validate public-key authentication by pointing Connection > SSH > Auth > Private key file at a `.ppk` and connecting. Success is indicated by the absence of a password prompt.
Rollback
Saving a session changes state by writing to the Windows Registry. To remove a saved session, open PuTTY, select the session in the list, and click Delete. Because the data lives under `HKCU`, removal affects only the current Windows user and does not require administrator rights.
Limitations and version assumptions
- PuTTY sessions are tied to the Windows user profile. Export to `.reg` to migrate sessions between machines or users.
- PuTTY does not read OpenSSH `~/.ssh/config` or standard Unix key paths natively on Windows.
- Unattended connections still need Pageant or external credential handling because passwords are not stored by default.
- Behavior can differ between PuTTY release branches. Check Help > About for your installed version before relying on newer SSH algorithms or UI changes.
This guide assumes a current PuTTY release that supports SSH-2 only. SSH-1 sessions are not supported.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.