git - Why can I clone from one machine, but not from another? -
i have own gitlab setup on own domain. have been using happily windows desktop, using gitbash. have been creating repos via gitlab web front end pushing codebase local machine so;
git remote add origin gitlab_user@my.gitlab.domain:my_namespace/my_repo.git
i can clone, this;
git clone gitlab_user@my.gitlab.domain:my_namespace/my_repo.git my_repo
no problems doing either of these on desktop.
if try , same centos box (the same 1 hosts gitlab domain, though may not be) prompted gitlab_user password. after this, same clone command tells me my_namespace/my_repo.git not appear git repository. know because have no problems accessing windows machine.
any ideas why isn't seeing repo when connect elsewhere, , why asking password?
the solution
in conclusion, indeed because did not have .ssh public key added user account in gitlab. steps fix were;
- ssh onto linux box user want clone as. have created user specially purpose.
ssh-keygen -t rsa -c "newuser@my.domain.com"
- (the -c part comment helps me work out key if ever forget.)- copy contents of public key (whilst still logged linux box new user)
cat ~/.ssh/id_rsa.pub
- log gitlab (as user has permission access project want clone) , add ssh key account, pasting public key copied in step 4.
now can clone using original command;
git clone gitlab_user@my.gitlab.domain:my_namespace/my_repo.git my_repo
what learned
i initially connect gitlab server user gitlab_user. upon arrival, gitlab identify user account claiming matching public key 1 stored against 1 of accounts has in database. that's why can't attach same .ssh key more 1 gitlab account - gitlab wouldn't know when connected.
however, can put more 1 (different) key on single account. example, need able access repo home , office, identified same gitlab user each time. creating .ssh key @ home , adding gitlab account, , doing same @ work. 2 different keys, identifying me same gitlab user.
Comments
Post a Comment