不需要在Ubuntu中输入git pull的密码

问题描述:

我试图在每次运行git pull时都通过密码提示。不需要在Ubuntu中输入git pull的密码

我在Ubuntu上运行。这是我的混帐配置:

git config --list 
user.name=Benlong Heng 
[email protected] 
credential.helper=cache --timeout=3600 
core.repositoryformatversion=0 
core.filemode=true 
core.bare=false 
core.logallrefupdates=true 
[email protected]:benlongheng/benlong-web-app.git 
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* 
branch.master.remote=origin 
branch.master.merge=refs/heads/master 
credential.helper=store 

我一直在下面this answer,出于某种原因,我仍然不断收到提示符下运行git pull后:

$ git pull 
Enter passphrase for key '/root/.ssh/id_rsa': 

我缺少的东西?任何提示?

+1

你是否以root身份进行开发?你真的不应该。 –

+0

不,我只是试图拉根。我在我的Mac上本地开发。我是Linux新手。 – ihue

+2

您使用密码保护了您的密钥。查看ssh-agent。 http://askubuntu.com/questions/362280/enter-ssh-passphrase-once – k0pernikus

您链接到的答案是HTTPS遥控器,但是这条线在你的配置:

[email protected]:username/repo.git 

表明您已经通过SSH连接。提示您输入密码的事实意味着您的密码保护了您的SSH密钥。要为当前会话缓存密码,这样做:

eval $(ssh-agent) 
ssh-add 

你会为你的密码一旦被提示,之后,它会被缓存。

如果您不希望被提示输入密码有史以来,那么您将需要生成一个没有密码短语的新密钥。我建议不要这样做,因为任何获取该密钥文件的人都可以在任何使用密钥的地方冒充你。


另外,我注意到了这一点:

Enter passphrase for key '/root/.ssh/id_rsa': 

它通常是一个坏主意,为root运行,所以我建议您尽快切换到另一个用户帐户。 (如果你不想因为任何原因使用你自己的帐户,你可以创建一个单一用途的帐户来代替。)

+0

'ssh-add'返回'无法打开与您的身份验证代理的连接。' – ihue

+1

感谢您的建议,我会创建一个除root以外的新用户来执行此操作。 – ihue

+0

@ihue更新我的回答:您必须先启动SSH代理。 –