[英]Mac ZSH shell “forgets” ssh keys
I'm trying to get Git to work, which keeps insisting that I don't have the correct access right (Permission denied, publickey), which lead me to this post , suggesting to inspect ssh-add
我试图让 Git 工作,它一直坚持我没有正确的访问权限(权限被拒绝,公钥),这导致我这篇文章,建议检查
ssh-add
I noticed that, indeed, ssh-add -l
returned我注意到,确实,
ssh-add -l
返回了
The agent has no identities.
代理没有身份。
So, I added an identity所以,我添加了一个身份
ssh-add ~/.ssh/ssh_key
Which returned exit code 0 (from echo $?
)哪个返回退出代码 0(来自
echo $?
)
Now, ssh-add -l
shows that I have a key added.现在,
ssh-add -l
显示我添加了一个密钥。 However, once I quit and re-open terminal, the key disappears.但是,一旦我退出并重新打开终端,密钥就会消失。
ssh-add -l
returns "The agent has no identities." ssh-add -l
返回“代理没有身份”。 all over again.重新来过。
Does anyone know how I can add the key so that it sticks?有谁知道我如何添加密钥以使其粘住?
You could add the ssh-add -K to your ~/.bash_profile
您可以将 ssh-add -K 添加到您的
~/.bash_profile
But check first if your SSH connection is working with a key not passphrase protected:但首先检查您的 SSH 连接是否使用不受密码保护的密钥:
ssh-keygen -t rsa -P "" -f ~/.ssh/test
(register test.pub
to the remote server ~/.ssh/authorized_keys
or the remote GitHub profile SSH page) (将
test.pub
注册到远程服务器~/.ssh/authorized_keys
或远程 GitHub 配置文件 SSH 页面)
ssh -i ~/.ssh/test user@remote_server
# or, if this is github
ssh -T -i ~/.ssh/test git@github.com
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.