【发布时间】:2013-11-11 04:42:30
【问题描述】:
有没有办法生成证书等,以便我的产品服务器可以从我的 github 存储库中提取,而无需我每次都进行身份验证?
【问题讨论】:
标签: git authentication github certificate
有没有办法生成证书等,以便我的产品服务器可以从我的 github 存储库中提取,而无需我每次都进行身份验证?
【问题讨论】:
标签: git authentication github certificate
您可以create an access token 并将其用作用户名(无需密码)。
获得访问令牌后,克隆存储库:
git clone https://<your-access-token>@github.com/username/repo.git
然后你可以不用每次都进行身份验证来拉取。
这是最简单的方法,但会将令牌纯文本存储到 .git/config 以提高安全性,您可以setup password caching 并照常克隆 https:
git clone https://github.com/username/repo.git
如果您想删除服务器对存储库的访问权限,只需删除您的application settings 中的访问令牌即可。
我也更喜欢在部署环境中使用 https 而不是 ssh。有时我们没有足够的访问权限来处理 ssh,但即使在更便宜的托管服务上也可以使用 https 访问 github。
【讨论】:
git clone https://<your-user-name>:<your-access-token>@github.com/username/repo.git。
git clone https://<your-access-token>@github.com/username/repo.git。看起来用户不是必需的。
【讨论】:
生成 ssh 密钥
cd ~/.ssh
ssh-keygen -t rsa -C "your-email-address"
touch config
粘贴到配置中
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/YOUR_KEY
将公钥粘贴到 github 部署密钥设置
cat YOUR_KEY.pub
将远程从 http 设置为 ssh
git remote set-url origin ssh://git@github.com/USERNAME/REPOSITORY.git
【讨论】:
set-url origin ssh 是我这边缺少的部分。谢谢。
我认为这可以通过使用凭证缓存和使用 .netrc 文件来完成。 Please Check This
【讨论】: