Git 配置为 pull/push WITH 密码
Git configuration to pull/push WITH password
我是 运行 Ubuntu Macbook Pro 上使用 VMware Fusion 的 14.04 虚拟机。我的 git 存储库也可以从 OSX 和 Ubuntu(作为共享目录)访问,但是 git 与 BitBucket 的通信方式不同 - git pull
和 git push
命令在 Ubuntu 中要求输入密码,但它们在 OSX 中无需密码即可工作。
配置文件:
- 两种情况下
/etc/gitconfig
文件都不存在
- 两种情况下的
~/.gitconfig
文件内容是一样的
.git/config
文件在物理上是相同的
Git Ubuntu 上的版本是 1.9.1,OSX 上的版本是 1.9.5。
我应该在哪里寻找造成这种差异的原因?我实际上也更喜欢在 OSX 中输入密码,因为它是半私人机器。
Where should I look to find out the reason for this difference?
这取决于使用的 url(git remote -v
的输出)
https:OSX 会话可能有 cached the password with the oskeychain helper.
您需要 cache credential helper in Ubuntu 才能获得相同的结果。
ssh: git正在寻找~/.ssh
中的ssh密钥,可以在[=36]中适当设置=] OSX 会话,但在 Ubuntu VM 中为空。
您需要在 Ubuntu ~/.ssh
文件夹中使用相同的密钥,以避免 ssh 退回到 username/password 身份验证。
请使用 SSH 访问 pull/push,无需密码。
参考:https://confluence.atlassian.com/bitbucket/set-up-ssh-for-git-728138079.html
When you use HTTPS, you authenticate (supply a username and password) each time you take an action that requires a connection with Bitbucket. Who wants to do that? This page shows you how to use secure shell (SSH) to communicate with the Bitbucket server and avoid having to manually type a password all the time.
步骤 1:生成 ssh 密钥,从终端或 Git Bash
ssh-keygen
第二步: 确认默认路径.ssh/id_rsa
输入密码(推荐)或留空。
请记住此密码,因为您将需要它来解锁
随时使用它的关键。
步骤 3:打开 ~/.ssh/id_rsa.pub 并将内容复制并粘贴到
你的服务器。
注意 id_rsa.pub 是您的 public 密钥,可以共享,
而 id_rsa 是您的私钥,应该保密。
步骤 4:重新检查,在 Git Bash 中键入
ssh -p 29418 YOUR_NAME@YOUR_SERVER.com
检查结果。如果成功
**** Welcome to Gerrit Code Review ****
Hi , you have successfully connected over
SSH.
git clone
ssh://YOUR_NAME@YOUR_SERVER.com:29418/REPOSITORY_NAME.git
步骤 5:更改 git 的远程目录。输入 Git Bash 来替换你的 link.
git remote set-url origin ssh://YOUR_NAME@YOUR_SERVER.com:29418/REPOSITORY_NAME.git
我是 运行 Ubuntu Macbook Pro 上使用 VMware Fusion 的 14.04 虚拟机。我的 git 存储库也可以从 OSX 和 Ubuntu(作为共享目录)访问,但是 git 与 BitBucket 的通信方式不同 - git pull
和 git push
命令在 Ubuntu 中要求输入密码,但它们在 OSX 中无需密码即可工作。
配置文件:
- 两种情况下
/etc/gitconfig
文件都不存在 - 两种情况下的
~/.gitconfig
文件内容是一样的 .git/config
文件在物理上是相同的
Git Ubuntu 上的版本是 1.9.1,OSX 上的版本是 1.9.5。
我应该在哪里寻找造成这种差异的原因?我实际上也更喜欢在 OSX 中输入密码,因为它是半私人机器。
Where should I look to find out the reason for this difference?
这取决于使用的 url(git remote -v
的输出)
https:OSX 会话可能有 cached the password with the oskeychain helper.
您需要 cache credential helper in Ubuntu 才能获得相同的结果。ssh: git正在寻找
~/.ssh
中的ssh密钥,可以在[=36]中适当设置=] OSX 会话,但在 Ubuntu VM 中为空。
您需要在 Ubuntu~/.ssh
文件夹中使用相同的密钥,以避免 ssh 退回到 username/password 身份验证。
请使用 SSH 访问 pull/push,无需密码。
参考:https://confluence.atlassian.com/bitbucket/set-up-ssh-for-git-728138079.html
When you use HTTPS, you authenticate (supply a username and password) each time you take an action that requires a connection with Bitbucket. Who wants to do that? This page shows you how to use secure shell (SSH) to communicate with the Bitbucket server and avoid having to manually type a password all the time.
步骤 1:生成 ssh 密钥,从终端或 Git Bash
ssh-keygen
第二步: 确认默认路径.ssh/id_rsa 输入密码(推荐)或留空。 请记住此密码,因为您将需要它来解锁 随时使用它的关键。
步骤 3:打开 ~/.ssh/id_rsa.pub 并将内容复制并粘贴到 你的服务器。
注意 id_rsa.pub 是您的 public 密钥,可以共享, 而 id_rsa 是您的私钥,应该保密。
步骤 4:重新检查,在 Git Bash 中键入
ssh -p 29418 YOUR_NAME@YOUR_SERVER.com
检查结果。如果成功
**** Welcome to Gerrit Code Review ****
Hi , you have successfully connected over SSH.
git clone ssh://YOUR_NAME@YOUR_SERVER.com:29418/REPOSITORY_NAME.git
步骤 5:更改 git 的远程目录。输入 Git Bash 来替换你的 link.
git remote set-url origin ssh://YOUR_NAME@YOUR_SERVER.com:29418/REPOSITORY_NAME.git