glide icon indicating copy to clipboard operation
glide copied to clipboard

Cannot use private repository

Open F21 opened this issue 9 years ago • 7 comments

I have a private repository hosted on gitlab.com. I can access the repo using my encrypted SSH key:

ssh -T [email protected]
Enter passphrase for key '/c/Users/user/.ssh/id_rsa':
Welcome to GitLab, Username!

This is my glide.yaml:

package: github.com/company/myproject
import:
- package: gitlab.com/company/mydependency
  version: ^0.1.0
  repo:    [email protected]:company/mydependency.git
  vcs:     git

When I run glide install --strip-vendor, it says that my private repo could not be found:

[WARN]  Unable to checkout gitlab.com/company/mydependency
[ERROR] Update failed for gitlab.com/company/mydependency: Unable to get repository
[ERROR] Failed to do initial checkout of config: Unable to get repository

I also see the problem if I try using http:

package: github.com/company/myproject
import:
- package: gitlab.com/company/mydependency
  version: ^0.1.0
  repo:    https://gitlab.com/company/mydependency.git
  vcs:     git

Glide is built using master: 21ff6d397ccca910873d8eaabab6a941c364cc70

F21 avatar Dec 01 '16 04:12 F21

It seems that the problem is that git is not prompting for my ssh key's password when used with glide. It does prompt for it if I use git clone directly:

[WARN]  Unable to checkout gitlab.com/company/myproject
[ERROR] Update failed for gitlab.com/company/myproject: Unable to get repository
[DEBUG] Output was: Cloning into 'C:\Users\user\.glide\cache\src\git-gitlab.com-company-myproject'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.[DEBUG]       Unlocking git-gitlab.com-company-myproject
[ERROR] Failed to do initial checkout of config: Unable to get repository
[DEBUG] Output was: Cloning into 'C:\Users\user\.glide\cache\src\git-gitlab.com-company-myproject'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

F21 avatar Dec 01 '16 06:12 F21

i suppose probably this is the same underlying issue as #411...

the typical solution here is to use an ssh-agent so that ssh doesn't need to prompt you for the password. is that not feasible in your environment?

sdboyer avatar Dec 01 '16 20:12 sdboyer

@sdboyer Thanks, I was able to set up git bash to run the ssh agent on start up by using this guide: https://help.github.com/articles/working-with-ssh-key-passphrases/#platform-windows and got it working.

However, in my case, I was never prompted to enter my ssh passkey, unlike #411

F21 avatar Dec 01 '16 22:12 F21

Any update on this? How can I set up it to work (for example) with gitlab in an automated fashion? (like using pipelines for example) Does it use HTTPS or SSH?

koalalorenzo avatar Aug 11 '17 20:08 koalalorenzo

Yeah, I have exactly the same question as above. I want to build using glide and this is an issue. How can I provide my https token as env variable to glide?

Reifier avatar Dec 20 '18 19:12 Reifier

Same question on how to solve this.

noprom avatar Apr 16 '19 13:04 noprom

A sample working with gitlab runner and docker

  • glide.yaml
package: gitlab.you/project/path
import:
- package: gitlab.you/package/project/path
  repo:    [email protected]:package/project/path.git
  • .gitlab-ci.yml
do stuff:
  script:
# ssh-keygen -t ed25519 -b 4096 -C "[email protected]"
    - test ! -d ~/.ssh && mkdir ~/.ssh
    - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
    - test -e "${id_rsa}" && cp "${id_rsa}" ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
    - test -e "${id_ed25519}" && cp "${id_ed25519}" ~/.ssh/id_ed25519 && chmod 600 ~/.ssh/id_ed25519
    - ssh -T [email protected] # test only should respond "Welcome to GitLab, @bot!"
    - glide install

this need ssh key id_rsa or id_ed25519 set in CI file variable, and public key added to valid account like a bot with reporter access

ax1036 avatar Aug 24 '20 18:08 ax1036

ok,亲~~~

fengkongling avatar Nov 02 '22 08:11 fengkongling