Error Connecting To Agent: Unknown Error’ in CIRCLECI Windows VM

RamanaReddy V
2 min readSep 5, 2021

CIRCLECI :
It automates your software builds, tests, and deployments on cloud or on your own infrastructure.

Use Case :

Let’s assume we’ve dedicated AWS EC2 windows server . we need to use CIRCLECI as build & deployment tool. Every developer commits in bitbucket should be trigger a CIRCLECI build| deployment job’s. Let’s take we’ve Dot Net core application in bitbucket it’s should be build on CIRCLECI windows orb(i.e. circleci/windows@2.4.0) and deploy build files into AWS EC2 box using SSH Authentication.

While implementing above use case I'm getting ‘Error Connecting To Agent: Unknown Error’ like below. I started ssh-agent in CircleCI windows VM. It’s seems running even though I got below issue.

Issue

Solution:

To overcome above issue we used Git bash (i.e. CircleCI windows orb will hold this by default) as hacky way instead of using PowerShell. So we mixed both shell + PowerShell script to overcome above issue.

Sample SSH deployment Script using SSH agent :

# Started  SSH AGENT within GIT BASH
eval `ssh-agent -s`
#ADD SSH Private key
ssh-add $HOME/.ssh/$AWS_PRIVATE_KEY_NAME
# Stop app pool in IIS
SSH $AWS_SERVER_USER@$AWS_SERVER_HOSTNAME "Stop-WebAppPool -Name DefaultAppPool"
...........

For more details about CIRCLECI CICD please visit below link.

NOTE: ABOVE CICD JOB ONLY FOR DEDICATED SERVER WITH SOME DOWN TIME OF OUR APPLICATION.

Reference:
1. https://circleci.com/
2. https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse
3. https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_server_configuration
4.https://circleci.com/docs/2.0/deployment-examples/#ssh

Note:

I’m sharing this as per my knowledge. Anywhere, I did wrong. please let me know. I want to update myself.

=============== Happy Coding ===============

--

--