如何在对vps服务器执行git推/拉操作时禁用询问密码?

如何在对vps服务器执行git推/拉操作时禁用询问密码?,git,automation,Git,Automation,有没有办法用本地git存储库设置服务器密码?每次我推送服务时,都会要求我提供密码。我想用一次性配置使它自动运行 查看您的.git/config文件。 远程部分将如下所示: [remote "origin"] url = https://url.tld 换成 [remote "origin"] url = git@url:/path/on/server 然后它将使用SSH。 您可以将SSH密钥复制到服务器上,并且不会再被要求输入密码这取决于您的URL(git remote-v在

有没有办法用本地git存储库设置服务器密码?每次我推送服务时,都会要求我提供密码。我想用一次性配置使它自动运行

查看您的
.git/config
文件。 远程部分将如下所示:

[remote "origin"]
    url = https://url.tld
换成

[remote "origin"]
    url = git@url:/path/on/server
然后它将使用SSH。 您可以将SSH密钥复制到服务器上,并且不会再被要求输入密码

这取决于您的URL(
git remote-v
在本地存储库中显示密码)

  • HTTPS意味着您需要激活
  • SSH意味着它要求您提供保护私钥的密码短语(您需要)
    或者:您没有将公钥添加到服务器帐户
    ~/.ssh/authorized_keys
    文件中,并且ssh返回到该服务器帐户密码

git提供凭证的存储

$ git config credential.helper store
$ git push http://example.com/repo.git
Username: <type your username>
Password: <type your password>

[several days later]
$ git push http://example.com/repo.git
[your credentials are used automatically]
$git config credential.helper存储
$git推送http://example.com/repo.git
用户名:
密码:
[几天后]
$git推送http://example.com/repo.git
[您的凭据将自动使用]
它基本上是将凭证存储在.git凭证文件中
https://user:pass@example.com
检查这些官方文件:

在配置文件中,我的url看起来像这样的url=ssh://root@74.208.23.154/var/repo/site.git