SSH without password: PuTTY or Git Bash

We access remote Linux servers everyday from our Windows computers. Having different servers for different projects, it can be difficult having to enter the passwords over and over in everyday. And so, I suggest that we use SSH Keys instead for authentication to save us some time and boost productivity. SSH keys should also make logins more secure than passwords — just be careful when someone else uses your computer.

I’ll show you two methods that we can use to connect to our Linux servers using SSH keys and without a password.

Method 1: PuTTY
Method 2: Git Bash

Requirements for this tutorial:

I personally like using Git Bash to connect via SSH to our server because it’s done in fewer steps than when using PuTTY, but in this tutorial I will first show you password-less connection to SSH via PuTTY.

Method 1: SSH Connection without password in PuTTY

  1. Download PuTTY from the PuTTY Download Page if you haven’t yet. No installation is required — you just run this .exe file when you need it.
  2. You also need PuTTYgen so if you don’t have it yet, download PuTTYgen from the PuTTY Download Page. This is the PuTTY Key Generator, and will be used to generate a key later. Like putty.exe, no installation is needed for this.
  3. Right click on puttygen.exe then run it.
  4. Make sure that under Parameters, SSH-2 RSA is selected, then click the Generate button. Move your mouse pointer all over the blank area to hasten the key generation.
  5. Copy the generated key, edit the Linux server’s authorized_key file in the .ssh folder (e.g. /home/username/.ssh), and paste the generated key into it. If the .ssh folder or authorized_key  file do not exist yet, create a .ssh folder with permission 700, then create the file authorized_key file with permission 600.
  6. In PuTTY Key Generator, click “Save public key” and save it as a .txt file.
  7. Still in PuTTY Key Generator, click “Save private key” and save it as a .ppk file. It’s recommended for you to save a passphrase for the private key.
  8. Now, run PuTTY. Go to Connection -> SSH -> Auth. Click the browse button to find and select the private key (.ppk file) that you saved in the previous step.
  9. From Connection, go to Session so that you can connect to the Linux server via SSH. Enter the host name or IP address then click Open.
  10. Enter your username.
  11. You should be logged in now without being prompted for password. I think you need to select the .ppk file under Connection -> SSH -> Auth each time you will log in.

Method 2: SSH Connection without username & password in Git Bash

  1. Install Git on your Windows computer if you haven’t yet. Download Git here. During setup, I didn’t change any setting aside from ticking the “Enable file system caching” checkbox.
  2. If a .ssh folder doesn’t exist yet under C:\Users\<YOUR-WINDOWS-USERNAME>\ then please create it. (I used the browser for Local Site in FileZilla to create .ssh folder)
  3. While inside the .ssh window, right click then choose Git Bash Here.
  4. Run this command: ssh-keygen -t rsa -C "[email protected]", then type the file name for your key (we’ll use this in a config file later), and then type the passphrase that you want to use, twice.
  5. Create a file named config, with no extension name, under the .ssh folder. (FileZilla’s browser for Local Site might help again)
  6. Paste the following into the config file and edit as necessary. <NAME_OF_SSH_KEY> should be the file name you typed earlier after the ssh-keygen command.
  7. Open the .pub key file that you just generated in C:\Users\<YOUR-WINDOWS-USERNAME>\.ssh\ and copy its contents.
  8. Edit the Linux server’s authorized_key file in the .ssh folder (e.g. /home/username/.ssh), and paste the key from the .pub file into it. If the .ssh folder or authorized_key  file do not exist yet, create a .ssh folder with permission 700, then create the file authorized_key with permission 600.
  9. Run Git Bash then enter this command: ssh <LABEL_FOR_CONNECTION> The label for connection should be as set in the config file. If you set a passphrase, you will be prompted for that too.
  10. Just run the same command in Git Bash each time you want to start the connection.

 

Resources:

Let me link to the web pages that helped me complete this tutorial:

HOW TO PASSWORDLESS SSH LOGIN – Server Mom explains how passwordless SSH connections work and will teach you how to implement a Linux to Linux or Windows to Linux connection. This page mostly helped me with Method 1: PuTTY.

Adding SSH Keys to Authorized_Keys – this page was my reference for chmod settings

Simplify Your Life With an SSH Config File – helped me complete the Method 2: Git Bash.

Related Posts:

Posts that may be related to "SSH without password: PuTTY or Git Bash":

Catzie

A Filipino programmer with a variety of interests such as baking, singing, making up silly song/rap lyrics, K-pop, drawing, creating unique dessert flavors, obsessing about finding out how some things works, board games, anime, video games, and forgetting things that usually go in her long list of interests. Running small-time online dessert shops Cookies PH and Catzie's Cakery.

Leave a Reply

Your email address will not be published. Required fields are marked *