npm install is unable to fetch dependencies because ssh-agent is terminated after git fetch/clone


I'm using ssh keys to access git repos, defined in VCS for the given project.

Cloning is done from a private github repos (, which is a Node project. This works fine, the issue is with the Node.JS NPM build runner, where I issue the commands:


Prune command works fine, install fails since it is trying to fetch a dependency that is on a private github repo as well accessible with the same ssh credentials that are used in the VCS for the build.

Sample from package.json in repoA:

"dependencies": {
"private-repoB": "git+ssh://",

RepoA has this fetch URL in VCS:

The reason why npm install fails is is because TeamCity will terminate the ssh-agent AFTER during the initial git clone/fetch during a checkout of the source code defined in the VCS. This is described in the documentation here:

During the build with agent-side checkout, the Git plugin downloads the key from the server to the agent. It temporarily saves the key on the agent's file system and removes it after git fetch/clone is completed.

How can I configure TeamCity to be able to use the ssh authentication keys during git clone, when doing an npm install ?


Hi Tore,

Could please check the SSH agent build feature


This will work. Thanks. You can close this issue.


Please sign in to leave a comment.