user762579
user762579

Reputation:

GitLab cannot push to remote - SSH key missing - generic SSH entry in .ssh/config

After creating a new repo (local + remote), I am trying to push commits. However I get an issue with the SSH key

In my ~/.ssh/config , I have an entry for gitlab defined as

Host MyRepoJD
HostName gitlab.myrepo.ninja
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitlab_myRepo/johnDoe

when I try to push from my ruby script, to the newly created repo in gitlab ( gran_torino_sa/mar_arch group: gran_torino_sa project: mar_arch) it's failing as there is no entry for this newly created repo...

ssh: Could not resolve hostname    
gitlab.myrepo.ninja:gran_torino_sa/mar_arch.git: nodename nor servname provided, or not known

Is there a way to define only ONE entry for any group/project created or is it mandatory to add an entry for each new group/project?

Upvotes: 2

Views: 3444

Answers (1)

user762579
user762579

Reputation:

myrepoafter debugging again ... found the solution in this post

"Specify an SSH key for git push for a given domain" Specify an SSH key for git push for a given domain

Host gitlab_as_johndoe
  HostName gitlab.myrepo.ninja
  User git
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/gitlab_myrepo/johndoe
  IdentitiesOnly yes

and using

  git remote add origin git@gitlab_as_johndoe:gran_torino_sa/mar_arch.git"

did the trick...

Upvotes: 1

Related Questions