Is there a way to make go dep working with private repo ( with ssh key )?

blov · 2018-01-09 23:30:16 · 720 次点击    
这是一个分享于 2018-01-09 23:30:16 的资源,其中的信息可能已经有所发展或是发生改变。

I've read a few tickets on Github about this issue, but was anyone able to make it work somehow? I'm trying to use go dep for some internal packages but it always fail / get stuck...


评论:

colek42:

in your .gitconfig use the "insteadof" directive and always use ssh

# Enforce SSH
[url "ssh://git@github.com/"]
  insteadOf = https://github.com/
[url "ssh://git@gitlab.com/"]
  insteadOf = https://gitlab.com/
[url "ssh://git@bitbucket.org/"]
  insteadOf = https://bitbucket.org/

ref: https://stackoverflow.com/questions/11200237/how-do-i-get-git-to-default-to-ssh-and-not-https-for-new-repositories

zelenin:

gogs/gitea with custom ssh port:

[url "ssh://git@git.domain.com:10022/"]
    insteadOf = https://git.domain.com/
Thaxll:

This what I have but for some reason the git CLI is stuck during git ls-remote / git-upload-pack ... :/

condanky:

Hey, what I have done is created a constraint in the .toml file and set the repo source with a github token. For example https://@github.com/owner/repo.git That way dep will be able to download the repo. I haven't experimented with using a ssh key though.

Thaxll:

Unfortunately it's not for github :/ This issue only applies for stash / gitlab / bitbucket

PurplrGecko:

https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md#constraint

dep use installed git tool to download dependencies

d1mk0:

As @PurpleGecko mentioned it's using local git command.

What I've done is setup ssh-agent and added ssh key. Then go dep/get worked just fine for me. For example if you have ssh key in ~/.ssh/private-repo then:

$ ssh-add ~/.ssh/private-repo

Also, if you do it in the docker and you can't interact with console then you would need to add host to known_hosts before adding key. Below is example for bitbucket.

$ ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts


入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

720 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传