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

blov · · 619 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I&#39;ve read a few tickets on Github about this issue, but was anyone able to make it work somehow? I&#39;m trying to use go dep for some internal packages but it always fail / get stuck...</p> <hr/>**评论:**<br/><br/>colek42: <pre><p>in your .gitconfig use the &#34;insteadof&#34; directive and always use ssh</p> <pre><code># Enforce SSH [url &#34;ssh://git@github.com/&#34;] insteadOf = https://github.com/ [url &#34;ssh://git@gitlab.com/&#34;] insteadOf = https://gitlab.com/ [url &#34;ssh://git@bitbucket.org/&#34;] insteadOf = https://bitbucket.org/ </code></pre> <p>ref: <a href="https://stackoverflow.com/questions/11200237/how-do-i-get-git-to-default-to-ssh-and-not-https-for-new-repositories">https://stackoverflow.com/questions/11200237/how-do-i-get-git-to-default-to-ssh-and-not-https-for-new-repositories</a></p></pre>zelenin: <pre><p>gogs/gitea with custom ssh port:</p> <pre><code>[url &#34;ssh://git@git.domain.com:10022/&#34;] insteadOf = https://git.domain.com/ </code></pre></pre>Thaxll: <pre><p>This what I have but for some reason the git CLI is stuck during git ls-remote / git-upload-pack ... :/</p></pre>condanky: <pre><p>Hey, what I have done is created a constraint in the .toml file and set the repo source with a github token. For example <code>https://&lt;token&gt;@github.com/owner/repo.git</code> That way dep will be able to download the repo. I haven&#39;t experimented with using a ssh key though.</p></pre>Thaxll: <pre><p>Unfortunately it&#39;s not for github :/ This issue only applies for stash / gitlab / bitbucket</p></pre>PurplrGecko: <pre><p><a href="https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md#constraint" rel="nofollow">https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md#constraint</a></p> <p>dep use installed git tool to download dependencies</p></pre>d1mk0: <pre><p>As @PurpleGecko mentioned it&#39;s using local git command. </p> <p>What I&#39;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:</p> <p><code> $ ssh-add ~/.ssh/private-repo </code></p> <p>Also, if you do it in the docker and you can&#39;t interact with console then you would need to add host to known_hosts before adding key. Below is example for bitbucket. </p> <p><code> $ ssh-keyscan bitbucket.org &gt;&gt; ~/.ssh/known_hosts </code></p></pre>

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

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