Introduction
PuTTY is one of the most popular SSH clients for Windows, providing a simple way to connect to remote servers. For users who routinely connect to the same host, creating a Windows shortcut with pre-filled login credentials can save time and streamline the connection process. This guide will show you how to create a shortcut that launches PuTTY with your username and password already entered.
Important Security Note: Storing your password in plain text within a shortcut is inherently insecure. If unauthorized individuals gain access to your computer or the shortcut file, your credentials could be compromised. For improved security, consider using SSH keys or a dedicated password manager. This method is intended for convenience on trusted machines only.
Prerequisites
- PuTTY Installed: Ensure that you have the latest version of PuTTY installed. You can download it from the official PuTTY website.
- Basic Windows Knowledge: Familiarity with creating shortcuts and editing properties in Windows.
1. Locate the PuTTY Executable
Typically, PuTTY is installed in one of these directories:
C:\Program Files\PuTTY\putty.exe
C:\Program Files (x86)\PuTTY\putty.exe
Make a note of the correct path, as you will need it for the shortcut.
2. Create a New Windows Shortcut
- Right-click on your Desktop (or another folder where you want the shortcut).
- Select New > Shortcut from the context menu.
3. Configure the Shortcut Command
In the shortcut creation wizard, you will be prompted to enter the location of the item. In this field, type the full path to the PuTTY executable along with the necessary command-line options. For example (if your password includes special characters, see the FAQ below on how to escape them):
"C:\Program Files\PuTTY\putty.exe" -ssh -l your_username -pw your_password your_hostname_or_IP
Command Breakdown:
- “C:\Program Files\PuTTY\putty.exe”
The full path to the PuTTY executable (ensure the quotes are included if the path contains spaces). - -ssh
Forces PuTTY to use the SSH protocol. - -l your_username
Replaceyour_username
with the actual username you use to log in. - -pw your_password
Replaceyour_password
with your actual password. Remember: This is stored as plain text. - your_hostname_or_IP
Replace this with the hostname or IP address of the server you want to connect to.
Example:
"C:\Program Files\PuTTY\putty.exe" -ssh -l john_doe -pw secret123 192.168.1.100
4. Name Your Shortcut
- Click Next after entering the command.
- Enter a descriptive name for your shortcut (e.g., “SSH to 192.168.1.100”).
- Click Finish.
Now when you double-click the shortcut it will bring you straight into your Linux server without having to enter username or password.
Security Considerations
- Plain Text Vulnerability: The password is stored in plain text within the shortcut’s properties. This can be a security risk if your computer is accessible by others or if malicious software scans for such shortcuts.
- Alternative Methods: For enhanced security, consider using SSH key authentication instead of passwords. Tools like Pageant, PuTTY’s SSH authentication agent, allow you to load your private keys without exposing your password.
- File Permissions: Store the shortcut in a secure location with limited access permissions to reduce the risk of unauthorized access.
Conclusion
Creating a Windows shortcut with pre-configured PuTTY credentials can significantly simplify repeated SSH connections. While this method offers convenience, always balance ease of access with the need for security. When possible, opt for more secure authentication practices like SSH key-based authentication to safeguard your sensitive information.
FAQ: Common Customizations and Issues
Below are some frequently asked questions and issues raised by readers, along with possible solutions.
1. Using a Different Port
If your server is not using the default SSH port 22, you can specify a custom port with the -P
switch. For example, if the port is 2222:
"C:\Program Files\PuTTY\putty.exe" -ssh -P 2222 -l john_doe -pw secret123 your_hostname_or_IP
2. Special Characters in Password
If your password contains special characters like quotes, backslashes, or spaces, you need to enclose it in double quotes and escape certain characters. For example, if your password is my^p'@s\"$
, your shortcut might look like this:
"C:\Program Files\PuTTY\putty.exe" -ssh -l john_doe -pw "my^p'@s\"$" 192.168.1.100
Note how the internal double quote (\"
) is escaped with a backslash, and the entire password is surrounded by quotes to prevent the command line from breaking.
3. Using Advanced Settings (Bug-Compatibility, Fonts, Colors, etc.)
PuTTY offers many advanced settings that can be configured in the graphical interface (fonts, colors, bug-compatibility flags, etc.). If you want to launch PuTTY with these advanced options and still auto-login, create a saved session in PuTTY with all your preferred settings. Then use:
"C:\Program Files\PuTTY\putty.exe" -load "MySessionName" -pw your_password
Any advanced options you saved in “MySessionName” (including bug-compatibility flags) will be applied, and you’ll still skip the manual password prompt.
4. Running Commands Automatically on Login
You can use the -m
switch to run commands automatically upon login, combined with -t
to force the server to start a shell. For example:
"C:\Program Files\PuTTY\putty.exe" -ssh -l john_doe -pw secret123 -m "C:\cmds.txt" -t 192.168.1.100
In C:\cmds.txt
, you might have:
cd /var/www
/bin/bash
This will change to /var/www
and then launch the bash shell automatically.
5. Logging Session Output
PuTTY doesn’t provide a direct command-line switch for logging. However, you can enable logging under Session > Logging in the PuTTY GUI and save those settings to a named session. Then launch that session via -load
:
"C:\Program Files\PuTTY\putty.exe" -load "LoggingSession" -pw your_password
All session output will then be logged according to the preferences you set in the saved session.
6. Storing Password in a File
PuTTY does not support a parameter to read the password directly from a file (e.g., -pw "C:\Path\to\pwfile"
will not work). Storing your password in a text file is still insecure, so it’s generally better to either use SSH keys or rely on the -pw
parameter in the shortcut (with caution).
7. Multiple Hosts or Shortcuts
To quickly log in to different servers, you can create multiple shortcuts—each with a different host/IP or port. Alternatively, create multiple saved sessions in PuTTY, each configured for a different server, and use -load
to launch them.
Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.
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
-m
and-t
switches, and a simple text file containing your commands.Target example:
In
cmd.txt
, add your command. We also need to run/bin/bash
to start the shell:-m
instructs PuTTY and the SSH server to run a command instead of a shell. That’s why we have to use-t
override to force PuTTY to start the shell, and/bin/bash
incmd.txt
to 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" -t
part 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.