git 每次都从 github 拉取而无需身份验证
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19702067/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Pull from github without authentication every time
提问by Matt Welander
Is there a way to generate a certificate or such so that my prod server can pull from my github repo without me authenticating every single time?
有没有办法生成证书等,以便我的生产服务器可以从我的 github 存储库中提取,而无需我每次都进行身份验证?
采纳答案by Nevik Rehnel
This is what Deploy Keysare for.
这就是部署密钥的用途。
That help article explains what deployment authentication methods GitHub supports and gives some pointers to help decide between them.
那篇帮助文章解释了 GitHub 支持哪些部署身份验证方法,并提供了一些指导以帮助在它们之间做出决定。
In my limited experience, deployment SSH keys are probably the simplest to set up.
以我有限的经验,部署 SSH 密钥可能是最容易设置的。
回答by EHER
You can create an access tokenand use it as username (without password).
您可以创建访问令牌并将其用作用户名(无需密码)。
Once you have your access token clone the repository:
获得访问令牌后,克隆存储库:
git clone https://<your-access-token>@github.com/username/repo.git
Then you can pull without authenticating every single time.
然后,您无需每次都进行身份验证即可拉取。
This is the simplest method but will store the token plain text into .git/config To improve security you can setup password cachingand clone as usual https:
这是最简单的方法,但会将令牌纯文本存储到 .git/config 为了提高安全性,您可以像往常一样设置密码缓存和克隆 https:
git clone https://github.com/username/repo.git
If you want remove access of server to repository, just delete the access token in your application settings.
如果要删除服务器对存储库的访问权限,只需删除应用程序设置中的访问令牌。
I also prefer to use https than ssh on deploy environments. Some times we don't have enough access privileges to handle with ssh, but https access to github is available even on cheaper hosting services.
我也更喜欢在部署环境中使用 https 而不是 ssh。有时我们没有足够的访问权限来处理 ssh,但即使在更便宜的托管服务上也可以使用 https 访问 github。
回答by Zachary Gilmartin
generate ssh key
生成ssh密钥
cd ~/.ssh
ssh-keygen -t rsa -C "your-email-address"
touch config
paste in config
粘贴在配置
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/YOUR_KEY
paste public key to github deployment key settings
将公钥粘贴到 github 部署密钥设置
cat YOUR_KEY.pub
set remote from http to ssh
将远程从 http 设置为 ssh
git remote set-url origin ssh://[email protected]/USERNAME/REPOSITORY.git
回答by user2735206
I think this can be done by using credential caching and using the .netrc file. Please Check This
我认为这可以通过使用凭证缓存和使用 .netrc 文件来完成。 请检查这个