git 每次都需要 ssh 服务器的密码

标签 git ssh

我对服务器的访问权限有限。我做了什么:

服务器:

mkdir project.git
cd project.git
git init --bare

我的本地电脑(Windows):

git clone <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="eb86929e988e99858a868eab8692988e999d8e99c5888486" rel="noreferrer noopener nofollow">[email protected]</a>:project.git
// make some files
git commit -m 'init'
git push

我可以毫无问题地使用我的服务器(推、 pull 、分支等)。问题是每个操作都需要密码,这很烦人(我的密码很长)。

我正在尝试这个:git config credential.helper store


在 @VonC 回答后进行编辑

这是关于 SSH 配置,而不是 GIT。解决方案可在主题 Configuring Git over SSH to login once 中找到。但仅以 17 票垫底。

  1. 我已经配置了 GIT ssh key 。
  2. 我唯一要做的就是ssh-copy-id -i .ssh/id_rsa.pub <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e590968097898a828c8ba596968d968097938097cb868a88" rel="noreferrer noopener nofollow">[email protected]</a> *。完毕!不再需要密码。

完整的过程,包括生成 ssh key 可以在这里找到:SSH with authentication key instead of password *

*ssh 命令可从 Windows 上的 git-bash 获取

最佳答案

检查结果

ssh -Tv <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="137e6a666076617d727e76537e6a6076616576613d707c7e" rel="noreferrer noopener nofollow">[email protected]</a>

这将向您显示它正在尝试哪个 ssh key :您需要将公共(public) ssh key 位于服务器端,位于 ~username/.ssh/authorized_keys ,以便您的 ssh 连接到 < em>不默认使用用户名/密码身份验证方案。

关于git 每次都需要 ssh 服务器的密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46571618/

相关文章:

git - 如何获取Gitlab CI中当前分支的名称

GIT PULL 有效,但 GIT PUSH 无效?

ruby-on-rails - 使用 pem 文件与 capistrano 部署

hadoop2.6.0 sudo sbin/start-dfs.sh 失败

ruby-on-rails - 为什么我的部署用户不使用我的 ssh key ?

git - 无法使用 SSH 推送到 Github

git - 有没有办法每次都通过 web 界面手动上传差异来使用带有 git 的审查板?

git - 如果 current = base = other,为什么 'git-merge-file current base other' 会创建一个空的 'current' 文件?

ssh 配置主机限制

Git:git svn fetch 是如何工作的?