我对服务器的访问权限有限。我做了什么:
服务器:
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 票垫底。
- 我已经配置了 GIT ssh key 。
- 我唯一要做的就是
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/