在这里,我们将给大家分享关于为什么通过https从github存储库“gitpull”命令需要“sudo”作为前缀?的知识,让您更了解为什么用github的本质,同时也会涉及到如何更有效地Docker
在这里,我们将给大家分享关于为什么通过https从github存储库“git pull”命令需要“sudo”作为前缀?的知识,让您更了解为什么用github的本质,同时也会涉及到如何更有效地Docker:从私有GitHub存储库中获取、Docker:如何从Github存储库上的非主分支构建映像、Git Pull Github and Gitee or Gitlab、Git 针对 GitLab Github 配置 HTTP HTTPS SSH 代理的内容。
本文目录一览:- 为什么通过https从github存储库“git pull”命令需要“sudo”作为前缀?(为什么用github)
- Docker:从私有GitHub存储库中获取
- Docker:如何从Github存储库上的非主分支构建映像
- Git Pull Github and Gitee or Gitlab
- Git 针对 GitLab Github 配置 HTTP HTTPS SSH 代理
为什么通过https从github存储库“git pull”命令需要“sudo”作为前缀?(为什么用github)
我的操作系统是Ubuntu的,我有一些代码位于github.com,一切都很好,但有一天,当我input:
混帐拉
我被要求像往常一样input密码,然后我得到这个错误。
错误:访问https时无法连接到主机https://ghosert@github.com/ghosert/VimProject.git/info/refs fatal:HTTP请求失败
安装GitLab并让它在子域上运行
确切地说Git Bash for Windows'提示符被定义?
与Windows和Git与非法文件名问题
糟糕的解释器:从Git Bash运行Ruby时,Permission denied error
为什么从Git命令的长时间结果会导致我的PowerShell提示失败?
直到我尝试sudo前缀,如:
sudo git拉
它再一次像以前一样工作。 当git需要的时候,我似乎失去了访问https的权限。 任何人有这个想法?
git archive“input行太长。 “batch file错误
Git:在Windows上重命名目录(仅用于案例)
Git推送到cPanel账户 – 推送没有更新修改后的文件
将git remote name重命名为“upstream”
Git Bash不会运行我的python文件?
您发布的错误并不表示问题是权限。
error: Couldn't connect to host while accessing https://ghosert@github.com/ghosert/VimProject.git/info/refs fatal: HTTP request Failed
“HTTP请求失败”听起来像是一个连接问题。
我只是打赌,当你第一次输入的时候,你的网络连接失败了,当你用sudo键入它的时候,你的网络连接失败了,我怀疑这个问题对解决问题有什么影响。
更糟的是,现在可能已经搞乱了你的权限,请参考sarnold的答案。
我今天面临同样的问题,这是我的分析和解决方案。
我在我的Chrome浏览器的系统范围内设置了代理设置,出于某种目的,它似乎创建了一些环境变量,这些变量导致我的工作外壳相信他们没有连接性,因为我在作业完成时终止了代理服务器。 env变量没有被删除。
检查你的env是否有一些不必要的变量集。 env – 这个命令会显示你shell中设置的所有env变量。
变量:
http_proxy,https_proxy
删除它们,一切都将工作。
Docker:从私有GitHub存储库中获取
我正在尝试运行一个容器,该容器将公开私有GitHub存储库上的软件包中的golang服务。
由于我与GCE合作,因此我的入门图片是google / debian:wheezy。
安装所有必需的依赖项和工具后,我正在运行
RUN go get github.com/<my_org>/<my_package>
包裹是私人仓库。
我添加了GitHub SSH密钥以允许从私有存储库克隆到docker文件:
ADD priv/id_rsa /root/.ssh/id_rsaADD priv/id_rsa.pub /root/.ssh/id_rsa.pub
尽管如此,当go尝试克隆存储库时,我在go get流程中遇到了一个错误:
# cd .; git clone https://github.com/<my_org>/<my_package> /gopath/src/github.com/<my_org>/<my_package>Cloning into ''/gopath/src/github.com/<my_org>/<my_package>''...fatal: could not read Username for ''https://github.com'': No such device or addresspackage github.com/<my_org>/<my_package>: exit status 128
为了调试该问题,我正在从Dockerfile运行:
RUN ssh-keyscan -t rsa github.com 2>&1 >> /root/.ssh/known_hosts
这告诉我有一些问题。看起来好像验证私钥是可以的,但是在公钥上发生了奇怪的事情。这是完整的ssh-keyscan结果:
OpenSSH_6.0p1 Debian-4+deb7u2, OpenSSL 1.0.1e 11 Feb 2013Pseudo-terminal will not be allocated because stdin is not a terminal.debug1: Reading configuration data /etc/ssh/ssh_configdebug1: /etc/ssh/ssh_config line 19: Applying options for *debug1: Connecting to github.com [192.30.252.129] port 22.debug1: Connection established.debug1: permanently_set_uid: 0/0debug1: identity file /root/.ssh/id_rsa type 1debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048debug1: identity file /root/.ssh/id_rsa-cert type -1debug1: identity file /root/.ssh/id_dsa type -1debug1: identity file /root/.ssh/id_dsa-cert type -1debug1: identity file /root/.ssh/id_ecdsa type -1debug1: identity file /root/.ssh/id_ecdsa-cert type -1debug1: Remote protocol version 2.0, remote software version libssh-0.6.0debug1: no match: libssh-0.6.0debug1: Enabling compatibility mode for protocol 2.0debug1: Local version string SSH-2.0-OpenSSH_6.0p1 Debian-4+deb7u2debug1: SSH2_MSG_KEXINIT sentdebug1: SSH2_MSG_KEXINIT receiveddebug1: kex: server->client aes128-ctr hmac-sha1 nonedebug1: kex: client->server aes128-ctr hmac-sha1 nonedebug1: sending SSH2_MSG_KEX_ECDH_INITdebug1: expecting SSH2_MSG_KEX_ECDH_REPLYdebug1: Server host key: RSA 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48debug1: Host ''github.com'' is known and matches the RSA host key.debug1: Found key in /root/.ssh/known_hosts:1Warning: Permanently added the RSA host key for IP address ''192.30.252.129'' to the list of known hosts.debug1: ssh_rsa_verify: signature correctdebug1: SSH2_MSG_NEWKEYS sentdebug1: expecting SSH2_MSG_NEWKEYSdebug1: SSH2_MSG_NEWKEYS receiveddebug1: Roaming not allowed by serverdebug1: SSH2_MSG_SERVICE_REQUEST sentdebug1: SSH2_MSG_SERVICE_ACCEPT receiveddebug1: Authentications that can continue: publickeydebug1: Next authentication method: publickeydebug1: Offering RSA public key: /root/.ssh/id_rsadebug1: Server accepts key: pkalg ssh-rsa blen 279debug1: key_parse_private_pem: PEM_read_PrivateKey faileddebug1: read PEM private key done: type <unknown>debug1: read_passphrase: can''t open /dev/tty: No such device or addressdebug1: Trying private key: /root/.ssh/id_dsadebug1: Trying private key: /root/.ssh/id_ecdsadebug1: No more authentication methods to try.Permission denied (publickey).
我在专用/公共密钥上尝试过chmod 600和chmod 700,这没有帮助。
有什么线索吗?有谁成功运行go从docker的debian上的私人仓库中获取go?
答案1
小编典典经过一番破解之后,我发现了这一点。这不是理想的解决方案,因为它涉及安装SSH,以及在容器中构建私钥。这个例子基于官方的Docker
golang镜像(Debian Wheezy):
您的示例的主要区别在于您需要git config命令来强制使用ssh而不是默认的https。
FROM golangRUN apt-get update && apt-get install -y ca-certificates git-core sshADD keys/my_key_rsa /root/.ssh/id_rsaRUN chmod 700 /root/.ssh/id_rsaRUN echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /root/.ssh/configRUN git config --global url.ssh://git@github.com/.insteadOf https://github.com/ADD . /go/src/github.com/myaccount/myprivaterepoRUN go get github.com/myaccount/myprivaterepoRUN go install github.com/myaccount/myprivaterepo
Docker:如何从Github存储库上的非主分支构建映像
是否可以从Github存储库上的非主分支构建映像?
例如,我有一个存储库//github.com/myAccount/docker-myImage,它有一个分支开发,我想用于我的图像.不幸的是,以下命令似乎只允许从主分支构建:
docker build -t myAccount/myImage git://github.com/myAccount/docker-myImage
以下是man docker build的相关文档:
Building an image using a URL
This will clone the specified Github repository from the URL and use it as context.
The Dockerfile at the root of the repository is used as Dockerfile. This only works
if the Github repository is a dedicated repository.
docker build github.com/scollier/Fedora-Dockerfiles/tree/master/apache
Note: You can set an arbitrary Git repository via the git:// schema.
也许有一个替代方案,比如docker build -t myAccount / myImage git://github.com/myAccount/docker-myImage:development?
有关更多选项,请参见docker build command reference.
Git Pull Github and Gitee or Gitlab
GitHub实战系列汇总:http://www.cnblogs.com/dunitian/p/5038719.html
缩略Code:https://www.cnblogs.com/dotnetcrazy/p/9162259.html#code
git同时提交到github和gitee或gitlab 主要说说码云(Gitee)Gitlab原理一样(有Github也不太需要它了)【内附个性Div推送】
查看当前仓库对应的远程仓库地址
git remote -v添加远程仓库
git remote add 自定义名字 仓库地址
推送到码云 用户名是邮箱/个性化地址,密码你自己知道(如果github和gitee用户名和密码一样就更方便了)
git push gitee master
去码云看看:
再来个div的操作:# 修改仓库名(仓库名默认是origin)
git remote rename origin github #我是从github上克隆的,所以默认是github,如果你从码云克隆的库,记得设置gitee
以后推送就更鲜明了(修改了origin也可以用git push来默认推送到clone的那个远程仓库)
再拓展一下:# 比如你修改个名字啥的,那么仓库地址就变化了,那就使用(修改仓库对应的远程仓库地址):
git remote set-url origin 仓库地址
附录:码云在创建空项目的时候挺人性化的,但是多远程仓库也容易有小坑
知识点详解:
Git 仓库的基本操作
1.修改仓库名
一般来讲,默认情况下,在执行clone或者其他操作时,仓库名都是 origin 如果说我们想给他改改名字,比如我不喜欢origin这个名字,想改为 oschina 那么就要在仓库目录下执行命令:
git remote rename origin oschina这样 你的远程仓库名字就改成了oschina,同样,以后推送时执行的命令就不再是 git push origin master 而是 git push oschina master 拉取也是一样的
2.添加一个仓库
在不执行克隆操作时,如果想将一个远程仓库添加到本地的仓库中,可以执行
git remote add origin 仓库地址
eg: git remote add github https://gitee.com/lotapp/BaseCode.git注意:
1.origin是你的仓库的别名 可以随便改,但请务必不要与已有的仓库别名冲突
2.仓库地址一般来讲支持 http/https/ssh/git协议,其他协议地址请勿添加3.查看当前仓库对应的远程仓库地址
git remote -v这条命令能显示你当前仓库中已经添加了的仓库名和对应的仓库地址,通常来讲,会有两条一模一样的记录,分别是fetch和push,其中fetch是用来从远程同步 push是用来推送到远程
4.修改仓库对应的远程仓库地址
git remote set-url origin 仓库地址
缩略Code:
#查看当前仓库对应的远程仓库地址
git remote -v
#添加远程仓库
git remote add 自定义名字 仓库地址
#推送到码云(用户名是邮箱/个性化地址)
git push gitee master
# 修改仓库名(仓库名默认是origin)
git remote rename origin github #我是从github上克隆的,所以默认是github,如果你从码云克隆的库,记得设置gitee
# 比如你修改个名字啥的,那么仓库地址就变化了,那就使用(修改仓库对应的远程仓库地址):
git remote set-url origin 仓库地址
Git 针对 GitLab Github 配置 HTTP HTTPS SSH 代理
配置 git 代理
配置 git 的 http https 代理
Linux 和 Windows 都适用
# gitlab 服务器在国外下载速度速度收到很大影响。下面对 gitlab 配置 http https 代理。同理也可以对 github 配置 http https 代理。
git config --global http.https://gitlab.com.proxy socks5://127.0.0.1:1080
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080
# 其中 socks5://127.0.0.1:1080 换成你使用代理服务。如:
git config --global http.https://gitlab.com.proxy http://127.0.0.1:8080
配置 git 的 ssh 代理
Linux 系统
# 需要安装 openbsd-netcat 来实现转发,以 Manjaro Linux 安装为例:
sudo pacman -S openbsd-netcat
# 在用户目录下的 .ssh/ 创建 config 文件
vim ~/.ssh/config
# 详细配置如下
Host github.com
Host gitlab.com
ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p
HostName %h
Port 22
User git
IdentityFile ~/.ssh/id_rsa
IdentitiesOnly yes
Windows 系统
Windows 10 带有 connect 转发工具无需手动安装。同样也是在 在用户目录下(c:\User\username\.ssh\
)的 .ssh\
创建 config
文件
Host github.com
Host gitlab.com
ProxyCommand connect -S 127.0.0.1:1080 %h %p # -H 为 HTTP
HostName %h
Port 22
User git
IdentityFile ~/.ssh/id_rsa
IdentitiesOnly yes
关于为什么通过https从github存储库“git pull”命令需要“sudo”作为前缀?和为什么用github的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于Docker:从私有GitHub存储库中获取、Docker:如何从Github存储库上的非主分支构建映像、Git Pull Github and Gitee or Gitlab、Git 针对 GitLab Github 配置 HTTP HTTPS SSH 代理的相关知识,请在本站寻找。
本文标签: