SSH Login Without Password on Windows for Continuous Testing

SSH Public Key Authentication on Windows

Courtney Zhan
4 min readApr 9, 2023

Continuous Testing, for the most part, is a process of executing automated end-to-end (via UI, preferably) as regression testing. This process can involve many steps, and each step should work without human intervention (at all). This is the idea behind Automation.

One common trouble is authentication (such as checking out from a Git repository and copying a file to and from another remote server). On a testing machine, we need to achieve the following:

  • Password authentication (required)
    To retrieve the latest test scripts
  • No plain password is stored on the build machine
    For security reasons

A good solution is certificate-based authentication. Readers familiar with Linux/macOS probably already know SSH Public Key Authentication. You can do the same on Windows too. This article will show how to do Windows authentication in the context of Continuous Testing setup.

1. The Problem
2. Generate the key pairs
3. Add your public key to the remote server
4. Verify automatic login without password
5. Start a new build on BuildWise

1. The Problem

I had set up a new Windows Virtual Machine (as the build agent machine) to execute Appium + WinAppDriver tests (for a desktop app).

The test script folder: C:\work\XXX\gui-tests

The parent Git repository: courtney@macmini:~/XXX.git , on another Mac Mini machine, using SSH authentication.

Note: this approach works when the remote server is Linux or macOS.

After triggering a build on the BuildWise CT server, the BuildWise Agent starts to participate by executing the “prepare” steps. One of these steps is to fetch the latest test scripts from the parent Git repository.

BuildWise Agent stuck

I realized this stuck behaviour might be due to waiting for the user’s input. I started a command window and verified it by running git pull .

That’s the problem, it requires typing the password.

Press Ctrl+C to stop the command.

2. Generate the key pairs

Run the command below in a command window (cmd).

> ssh-keygen -t rsa

ssh-keygen is located at C:\Windows\System32\OpenSSH\ssh-keygen.exe

Keep pressing the “Enter” key to complete the command.

Assume the user is CIO, you will find a few files created under C:\Users\CIO\.ssh folder.

id_rsa.pub is your public certificate.

3. Add your public key to the remote server

Start a PowerShell window. (Piping doesn’t work in the regular command-line on Windows).

Run the command below. Change the certificate path, user name and password (in bold), for yours.

> type C:\Users\CIO\.ssh\id_rsa.pub | ssh zhimin@macmini 'cat >> ~/.ssh/authorized_keys'

It will ask for the password (for the user zhimin on the macmini machine). Type it in.

4. Verify automatic login without password

Start a new command window and run the previous git pull command.

No password required!

5. Start a new build on BuildWise

Cancel the build (currently stuck) on the BuildWise CT server and relaunch the BuildWise Agent. Trigger a new build.

After a few seconds, the BuildWise Agent starts executing test scripts (one by one).

--

--

No responses yet