避免在ubuntu中提示git命令的密码

时间:2014-11-18 00:39:23

标签: git ubuntu ssh passwords required

我在我安装了git的ubuntu服务器上设置了ssh。 所以,我将我的公钥附加到 安装了git的服务器的〜/ .ssh / authorized_keys文件。 我可以使用我本地电脑上的任何git命令(我的公钥粘贴在〜/ .ssh / authorized_keys中)

然而,我只是想知道每次使用git命令时如何避免输入密码。 这样我每次都可以避免输入密码。 谢谢

1 个答案:

答案 0 :(得分:0)

来自https://askubuntu.com/questions/362280/enter-ssh-passphrase-once

的回复
  

更新:似乎是13.10的错误:

     

https://bugs.launchpad.net/ubuntu/+source/libpam-ssh/+bug/1247169

     

无论如何运行以下命令我的问题已解决:   如何修复

     

我通过输入以下命令来修复此问题:

     

$ ssh-agent bash

     

这会创建一个新的bash进程,允许您添加私钥。   添加新私钥时,系统将提示您输入密码   曾经只有一次。

     

然后:

$ ssh-add /home/username/.ssh/id_rsa Enter passphrase for /home/username/.ssh/id_rsa:  Identity added:
     

/home/username/.ssh/id_rsa(home/username/.ssh/id_rsa)

     

...其中用户名是您的用户名。您可以使用$ USER执行相同的操作   变量:

$ ssh-add /home/$USER/.ssh/id_rsa
     

问题已解决。

重复:

Git enter long passphrase for every push

Git keeps asking me for my ssh key passphrase

修改

我知道的唯一方法是使用expect

#!/usr/bin/expect -f
set timeout -1
spawn ssh -o PubkeyAuthentication=no host.example.com
expect -exact "Password: "
send -- "secret\r"
expect {\$\s*} { interact }

并且可能处理ssh-config's ProxyCommand或使用python version这更复杂,并允许在配置文件中保留凭据。

作为一个注释 - 唯一可接受的解决方案(安全和方便)是基于身份验证的ssh密钥。