SSH Login Using PuTTY without Typing Username and Password

Table of Contents

Login Using PuTTY without Typing Username and Password

Typing username and password every time you connect to a remote Linux system using PuTTY may be tired. In this post, we will show you how to create a Windows shortcut, which will store your PuTTY session information so that you don’t have to enter the username and password every time you log in.

SSH Login Using PuTTY without Typing Username and Password

1. If you haven’t already installed PuTTY, you can download it from chiark.greenend.org.uk or from the below direct links:

2. Create a Windows Shortcut by right-click on the Desktop then select New > Shortcut.

SSH Login Using PuTTY without Typing Username and Password

3. Click Browse and navigate to the PuTTY folder. It’s usually located in C:Program FilesPuTTY or C:Program Files (x86)PuTTY. Select putty.exe then click OK.

SSH Login Using PuTTY without Typing Username and Password

4. Click Next.

SSH Login Using PuTTY without Typing Username and Password

5. Enter a desire name for your shortcut. e.g. MyLinuxServer and click Finish.

SSH Login Using PuTTY without Typing Username and Password

6. Now, right-click on your new shortcut and click Properties.

SSH Login Using PuTTY without Typing Username and Password

7. We are going to add a parameter to this. After the double quotes, paste in the following:

-ssh [email protected] -pw PassW0rd

Don’t forget to:

  • Replace bonben with your username.
  • Replace 10.10.5.77 with your server IP address or hostname.
  • Replace PassW0rd with your own password.

The Target field should now look something like this. (Your path may differ depending on where putty.exe is installed.)

"C:\Program Files\PuTTY\putty.exe" -ssh [email protected] -pw PassW0rd
SSH Login Using PuTTY without Typing Username and Password

8. Click OK and you’re done! Now when you double-click the shortcut it will bring you straight into your Linux server without having to enter username or password.

SSH Login Using PuTTY without Typing Username and Password

Using a batch file

Additionally, if you don’t want to create a shortcut, you can create a batch file with the same command when creating the shortcut.

Related:How to create a batch file on Windows.

SSH Login Using PuTTY without Typing Username and Password

Key-based authentication

Storing your password in a Windows shortcut is not very secure. As well as offering additional security, SSH key authentication can be more convenient than the more traditional password authentication. SSH keys can allow you to connect to a server, or multiple servers, without having to remember or enter your password for each system.

Generate Keys

1. We start the configuration at the client Windows computer. Download the latest version PuTTY Key Generator from the below link:

Note:If you’ve installed PuTTY on your computer. The PuTTYGen already exist in C:Program FilesPuTTY.

2. Using the PuTTYGen tool we have to generate an authentication key. This key will serve as a substitute for the password that will be entered during login.

SSH Login Using PuTTY without Typing Username and Password

3. Leave the default selections and click on the button. The following window opens. Move mouse randomly over the empty space below the progress bar to create some randomness in the generated key.

SSH Login Using PuTTY without Typing Username and Password

4. You don’t enter any key phrase. Let’s click on Save private Key button. Click Yes on the window asking for confirmation for saving the key without a password then save the key file to a safe location.

SSH Login Using PuTTY without Typing Username and Password

5. Now, copy the public key then save it into a text file for later uses.

SSH Login Using PuTTY without Typing Username and Password

Configure the Linux server

1. Close PuTTYgen and open PuTTY then connect to the remote system using the user you want to use for future with password prompt. This time when you login, you have to provide the password at the prompt. Future logins won’t require this password.

2. Under the logged in user’s home directory create a directory named ~/.ssh using the following command:

mkdir ~/.ssh

3. Enter the below command to giving users (owners) read, write and execute permissions.

chmod 700 ~/.ssh

4. Now, create an empty text file named authorized_keys using your favorite text editor.

nano ~/.ssh/authorized_keys

5. Paste the contents of the public key that you’ve saved in the previous step into authorized_keys file, then save and close the file.

Note

Tip: To save and close the file in nano editor, press > followed by > and then

SSH Login Using PuTTY without Typing Username and Password

6. Assign permissions only for the owner using the following command:

chmod 600 ~/.ssh/authorized_keys
SSH Login Using PuTTY without Typing Username and Password

Finally, type exit to close the SSH connection.

Configure the PuTTY client

Now we have configured SSH server, it’s time to test our setup. 

1. On the client system, open PuTTY. From the left navigation, select Connection > Data. Enter the username as Auto-login username on the right panel.

SSH Login Using PuTTY without Typing Username and Password

2. Again from the left navigation menu, scroll down and expand Connection > SSH > Credentials. Enter the path of the saved private key file (In our case C:privkey.ppk ). Leave other defaults as such and press Open button.

SSH Login Using PuTTY without Typing Username and Password

Now the PuTTY connects to the remote SSH server and there won’t be any password prompt.

SSH Login Using PuTTY without Typing Username and Password

Leave a Comment

Required fields are marked *