How to install private github repository via npm in github actions workflow ci

I am trying to install npm dependencies within a github workflow ci by running npm install. However i get the following error:

npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://
npm ERR!
npm ERR! Warning: Permanently added the RSA host key for IP address 'removed' to the list of known hosts.
npm ERR! Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.


name: CI

branches: [master]

runs-on: ubuntu-latest
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
node-version: '12.x'
- run: node --version
- run: npm install


"dependencies": {
"some-pacakage": "git+ssh://",

This some-package is being installed via github by npm. The repo is within the same organization as which the workflow is running in. To solve this problem locally you setup ssh key on your github account tied to the organization.

But how can i solve this issue so that its able to install that package via github repo within the workfow ci where im not using my personal github account.

Hi @kaykhan , 

There is an action which could help you setup ssh-agent on GitHub Hosted runner. 

- uses: webfactory/ssh-agent@v0.2.0
        ssh-private-key: ${{ secrets.private_ssh }}

You could copy the content of private ssh key (~/.ssh/id_rsa under the user folder ) in your local machine to a secret variable private_ssh. 

Then you could use the secret variable in your workflow with syntax ${{ secrets.varname }}. Please add webfactory/ssh-agent action in the front of npm install step. 

1 Like