Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple github private npm repositories on a server

I have a node application on github in a private repository. This node application also has custom modules that I made and they are in a separate private repository.

This is the example node application url:

[email protected]:thomas/node-application.git

These are both node modules that node application uses.

[email protected]:thomas/node-module1.git
[email protected]:thomas/node-module2.git

You can use the following to install a private npm module on github.

npm install git+ssh://[email protected]:thomas/node_module1.git

In order for this to work the machine needs to have ssh keys setup.

My local machine has my github user keys set up and access to all my repos.

On my server, however I'm using deploy keys. The only way I know how to use multiple deploy keys is as follows.

Host na.github.com
HostName github.com
User git
IdentityFile ~/.ssh/gh_node-application
ForwardAgent yes

Host nm1.github.com
HostName github.com
User git
IdentityFile ~/.ssh/gh_node-module1
ForwardAgent yes

Host nm2.github.com
HostName github.com
User git
IdentityFile ~/.ssh/gh_node-module2
ForwardAgent yes

So I'd need to install the modules on the server with

npm install git+ssh://[email protected]:thomas/node_module1.git
                          ^^^

Which means that the production and development dependancies would be different

"node-module": "git+ssh://[email protected]:thomas/node-module1.git"

vs

"node-module": "git+ssh://[email protected]:thomas/node-module1.git"
                              ^^^

This could work if I could do something like this…

Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/gh_node-application
IdentityFile ~/.ssh/gh_node-module1
IdentityFile ~/.ssh/gh_node-module2
ForwardAgent yes
like image 252
ThomasReggi Avatar asked Nov 12 '22 11:11

ThomasReggi


1 Answers

You have to give the server SSH access to your private github repos using Deploy Keys.

https://developer.github.com/guides/managing-deploy-keys/

like image 166
ThomasReggi Avatar answered Nov 15 '22 05:11

ThomasReggi