Deploying with Different SSH Keys via Github

Viewed 21

I'm trying to deploy my app to vultr.
I have two different repository for front and back app.

I created ssh key on server and added it to deploy keys section of my backend repository on GitHub.
I can pull backend app it's ok.

But When I try to add same ssh key into my deploy keys section of frontend app, it says "key is already in use".
Then I created another ssh key on server and added it into deploy keys of front end repository..
But that time when I try to clone app it tries to read ssh key that I first created...

I think I need some think like "clone by using a specific ssh key". How can I fix this?
Or is there an easier way to deploy different apps via using ssh?

1 Answers

To use your second key, you need to reference it in a ~/.ssh/config file with:

Host deploy
  Hostname github.com
  User git
  IdentityFile ~/.ssh/yourSecondSSHKey

The git clone deploy:YourGithubName/YourAppRepository

That would force Git/SSH to use your second key.

Related