Logging into the same SSH server from Windows day after day, you eventually want PuTTY to remember the username and password so a desktop shortcut just connects in one click. This DevAnswers guide shows you how to save your PuTTY username and password in a Windows desktop shortcut for one-click authenticated SSH on Windows 10 (build 1809+) and Windows 11, covering the -pw shortcut method first, then the safer Pageant + key-based authentication alternative for shared or security-conscious workstations.
Prerequisites
You’ll need:
- PuTTY 0.78 or later (current is 0.83 from chiark.greenend.org.uk)
- Windows 10 build 1809+ or Windows 11
- Access credentials to a remote Linux SSH server (username + password, or for the safer Pageant alternative below, an SSH key pair)
Step 1: Locate the PuTTY Executable
PuTTY is typically installed in one of these directories:
C:\Program Files\PuTTY\putty.exe(default 64-bit installer)C:\Program Files (x86)\PuTTY\putty.exe(32-bit installer on 64-bit Windows)- A custom path you chose during installation, or the directory you extracted a portable build to
Make a note of the full path; you’ll paste it into the shortcut wizard in the next step. To verify, open File Explorer, navigate to the folder, and confirm putty.exe exists.
Step 2: Create the Windows Shortcut
- Right-click on your Desktop (or any folder you’d like the shortcut to live in) and choose New → Shortcut. The Create Shortcut wizard opens.
- Paste the full path to
putty.exeinto the location box (the wizard won’t continue while it’s empty) and click Next. - Give the shortcut a descriptive name like
SSH to 192.168.1.100ordevbox-prod, then click Finish.
The shortcut appears on your Desktop. Right-click it, choose Properties, and you’ll see the Target field pre-filled with the PuTTY path; we’ll add the connection arguments next.
Step 3: Configure the Shortcut Command
Edit the Target field so it contains the full PuTTY path (in quotes if it contains spaces) followed by the connection arguments:
"C:\Program Files\PuTTY\putty.exe" -ssh -l john_doe -pw secret123 192.168.1.100
Command Breakdown
Per the official PuTTY documentation (Chapter 3), each flag does the following:
-ssh: force SSH protocol (the default for putty.exe, but explicit here is safer)-l john_doe: specify the login name on the remote server. Replacejohn_doewith your actual SSH username.-pw secret123: specify the password as a command-line argument. Replacesecret123with your actual password. Be aware: this is intended for non-interactive scripted use and exposes the password to other processes; see the Security Considerations section below.192.168.1.100: the hostname or IP address of the server. Replace with your actual host.
Click OK to save the Properties dialog. Double-clicking the shortcut now launches PuTTY and connects you straight to the remote shell, no username/password prompt.
Security Considerations (Pageant vs -pw)
The -pw approach passes your password as a command-line argument to putty.exe. That has three concrete exposures worth knowing before you decide it’s the right tradeoff for your machine:
- Plain text on disk: the password is stored in the shortcut’s
Targetfield. Anyone with read access to the .lnk file can recover it. - Process-list visibility: for the few seconds while PuTTY is launching, the full command line including
-pw <password>is visible in Task Manager’s Command Line column and to anyone running PowerShell’sGet-CimInstance Win32_Process(orwmic process get commandlineon older builds; WMIC is deprecated and absent from newer Windows 11 installs). - Audit log capture: if Group Policy enables Process Creation Auditing, the password lands in Windows Security event log entries (Event ID 4688) and from there into any SIEM the organization is shipping audit logs to. This is the most material exposure on managed enterprise workstations.
-pw. Generate a key pair with PuTTYgen, load the .ppk into Pageant via the system-tray icon (right-click → Add Key), and PuTTY will silently authenticate using the in-memory key, with no password ever on the command line. Pageant can be added to your Startup folder so the key auto-loads on Windows login. Full walkthrough in our PuTTY SSH key authentication guide. If you do stick with the -pw shortcut, mitigate the disk exposure by keeping the .lnk file in your user profile (not on a shared drive or in C:\Users\Public) and confirming the file’s NTFS permissions don’t grant Everyone read access. The process-list and audit-log exposures cannot be mitigated with the -pw approach; only key-based auth removes them entirely.
Alternative: Windows Terminal + Built-in OpenSSH
If you don’t specifically need PuTTY’s session manager and you’d rather use SSH keys instead of passwords, modern Windows ships everything you need natively. Windows 10 build 1809 (October 2018) and later, and all of Windows 11, include the OpenSSH client at C:\Windows\System32\OpenSSH\. ssh.exe is the main client, with ssh-keygen.exe for generating key pairs and ssh-add.exe for loading keys into the running ssh-agent service.
The equivalent of a saved PuTTY session is a Host block in your SSH config file at C:\Users\<you>\.ssh\config:
Host my-server
HostName 192.168.1.100
Port 22
User john_doe
IdentityFile ~/.ssh/id_ed25519
Once the Host alias is configured, connect from any terminal with a single command:
ssh my-server
For the one-click experience equivalent to a desktop shortcut, add a Windows Terminal profile that launches the same command. (Windows Terminal is preinstalled on Windows 11; on Windows 10 install it free from the Microsoft Store. The ssh.exe client itself works from any console either way.) Open Terminal Settings (Ctrl+,), Add a new profile, and set Command line to ssh.exe my-server. The profile then appears in Terminal’s dropdown menu, with key-based auth via the running ssh-agent service rather than -pw on the command line. Process-creation auditing can still log the ssh.exe command line itself, but it no longer contains any secret.
FAQ: Common Customizations and Issues
How do I use a non-default SSH port with the shortcut?
If your server is not using the default SSH port 22, specify a custom port with the -P switch (capital P, not lowercase p):
"C:\Program Files\PuTTY\putty.exe" -ssh -P 2222 -l john_doe -pw secret123 192.168.1.100
How do I escape special characters in a PuTTY password?
If your password contains quotes, backslashes, or spaces, enclose it in double quotes and escape any internal double quotes per cmd.exe rules:
"C:\Program Files\PuTTY\putty.exe" -ssh -l john_doe -pw "my^p'@s\"$" 192.168.1.100
Be aware of cmd.exe’s trailing-backslash pitfall: a password ending in a single backslash before the closing quote will escape the quote and break the parser. If your password ends in \, double the final backslash before the closing quote (-pw "secret123\\"), or better, switch to Pageant + key authentication.
How do I load a saved PuTTY session from the shortcut?
If you’ve configured a session inside PuTTY (with custom fonts, colors, terminal type, or keepalive settings) and want the shortcut to load it, use -load:
"C:\Program Files\PuTTY\putty.exe" -load "MySessionName" -pw secret123
How do I run commands automatically after login?
To run a script or sequence of commands as soon as the SSH session opens, write the commands to a local file and pass it via -m. The -t flag forces a pseudo-terminal so interactive commands like bash work:
C:\cmds.txt with Unix (LF) line endings, not Windows (CRLF). PuTTY sends the file byte-for-byte to the remote shell, and bash treats the carriage-return character (\r) as part of the command. A file like cd /var/www saved with CRLF reaches bash as cd /var/www, which produces errors like bash: line 1: $'\r': command not found or silently broken paths. Notepad defaults to CRLF on Windows; switch to LF in the bottom-right corner of Notepad++ (Edit → EOL Conversion → Unix (LF)), VS Code (click CRLF in the status bar → LF), or convert after the fact with dos2unix cmds.txt (WSL/Git Bash) or (Get-Content cmds.txt -Raw) -replace "`r`n","`n" | Set-Content -NoNewline -Encoding Ascii cmds.txt (PowerShell). cd /var/www
bash
The trailing bash keeps the session open after the commands run; it assumes bash is installed on the server, which is standard on Ubuntu, Debian, and RHEL-family systems. On a minimal distro without bash, end the file with sh instead.
"C:\Program Files\PuTTY\putty.exe" -ssh -l john_doe -pw secret123 -m "C:\cmds.txt" -t 192.168.1.100
Can I store the password in a file instead of the shortcut?
PuTTY does not support a flag to read the password from a file (-pwfile or similar does not exist). Workarounds with PowerShell or batch scripts that pipe a password into putty.exe exist but inherit the same exposures as -pw. The right answer here is Pageant + key-based authentication: see the Security Considerations section above and our PuTTY SSH key authentication guide.
How do I create shortcuts for multiple hosts?
For different servers, create one shortcut per host. Each shortcut has its own Target string with the appropriate hostname, port, and credentials. Once you’ve built up a collection of saved shortcuts and PuTTY sessions, see our guide on backing up PuTTY sessions to another PC.
Next Steps
If you’d rather skip the -pw exposures entirely, our PuTTY SSH key authentication guide walks through generating a key pair with PuTTYgen and loading it into Pageant. To migrate your saved PuTTY sessions to a new PC, see backing up PuTTY sessions. First time connecting to a Linux server from Windows? Start with our guide to connecting via SSH, which covers the built-in OpenSSH client and PuTTY. For network-error troubleshooting when the shortcut launches but the connection fails, see fixing PuTTY network errors.
Hi,
Thanks, this is very useful. May I ask what if the server uses a different port instead of 22
Is there away to change the default port
In addition to password, I’m setting dynamic port forwarding for FoxyProxy SOCKS proxy use (with -D 1234), but would like to start puTTY with one of its SSH bug-compatibility mode flags set to On, particularly the ‘Chokes on PuTTY’s SSH-2 ‘winadj’ requests’.
In a saved session with this flag set to On, I notice the BugWinadj REG_DWORD registry key has a value of 2
Can you think of a way to invoke puTTY with this flag set from a shortcut?
Thanks for any help!
Is it possible to save passoword in a file
like:
“C:Program FilesPuTTYputty.exe” -load web-server -pw “C:Program FilesPuTTYpw”
Creating youself a key pair for SSH and disabling password based login is greatly advised.
If you really want to create this autologin file, other than leaving an handy way to login to some intruder in your machine, do it with the key string then, at least you can then disable it in a cleaner way
Thank you, Edit Shortcut work with my win10 laptop.
Regards,
I would like to enter my session (“Cole”) details (user name “ME”, password “234”); then on the next screen enter my details (user name “ME”, password “567”). then with the same defined pages, enter there parameters and set to download in excel (3 pages in total) using excel vba.
is this possible?
It works good, thanks
Thank you so much with this el i m able to save my password
how do you open it directly to the destination folder, for example
\var\www\test\You can use the
-mand-tswitches, and a simple text file containing your commands.Target example:
In
cmd.txt, add your command. We also need to run/bin/bashto start the shell:-minstructs PuTTY and the SSH server to run a command instead of a shell. That’s why we have to use-toverride to force PuTTY to start the shell, and/bin/bashincmd.txtto force the SSH server to also start the shell.I can get the login part to work just fine – but as soon as I add the
-m "C:\Users\john\Desktop\cmd.txt" -tpart the shortcut can’t login. The putty is just waiting for me to enter the password manually – any advice?How to input PaSwOrD having double quotes in it ( ” ) ?
You may have to escape some special characters such as
"with a single backslash\.For example, if your password is
1234"1234, then your target will be:Thank you for this!!!
this works very well but is there a way to setup logging for the shortcut’s after doing this?
Not sure what you mean. Can you explain what you want to achieve?
Thank you for this. I had a profile setup with custom colors and font, is there a way to use this saved name/password with the custom colors/font?
There is no command line switch for font style that I know of but you can instead save a PuTTY session with your IP, username and font preference, and then load the session with password using:
I’ve just tested this and it works.
thanks for this trick, smart! also useful for using shh key connections which need more modifications in session
thank u so much -ssh was saying incoorect path ‘-load’ worked here
Thanks for post, is there way to save password for multiple host?
windows 10 gives an error message about invalid path & won’t allow the change.
Nevermind fix problem.
How did you fixed? I get error that the path is not correct
yes this helped a lot, what would be even better is automate task with this add on now.