Table of Contents
SSH Login Using PuTTY without Typing Username
In this post, how to SSH login using PuTTY without typing username. As you can see, by default, you need to type the username for login every time starting a connection.
1. From the session setting, we can bypass the username prompt when connect. Open PuTTY and select a session (which is usually highlighted) or any your saved session. Then click on Load.
2. Click the Data option under the Connection. Then enter your auto-login name in the box. In this example the login name is azureuser.
3. After configuring the login name, you need to:
- Select the Session option under the Category.
- Select a saved session in the saved session list. For example, select the ubuntu session.
- Select the Save button in the right side.
In the next times, when you connect to the server, the username specified is now passed along automatically without you having to type it in. All you need to do now is to the type in the password.
Key-based authentication
In some cases, you want to bypass both username and password for authentication. We can use the key-based authentication method. It’s more secure and is the recommended method for SSH login.
Generate Keys
Note: If you’ve installed PuTTY on your computer. The PuTTYGen already exist in C:\Program Files\PuTTY.
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.
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.
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.
5. Now, copy the public key then save it into a text file for later uses.
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.
6. Assign permissions only for the owner using the following command:
chmod 600 ~/.ssh/authorized_keys
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.
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.
Now the PuTTY connects to the remote SSH server and there won’t be any password prompt.
Not a reader? Watch this related video tutorial: