Dan*_*ves 183 command-line ssh ssh-agent
我一直在尝试ssh-add使用运行 Raspbian 的 RaspberryPi。
我可以开始ssh-agent,当我这样做时,会在终端中提供以下输出:
SSH_AUTH_SOCK=/tmp/ssh-06TcpPflMg58/agent.2806; export SSH_AUTH_SOCK;
SSH_AGENT_PID=2807; export SSH_AGENT_PID;
echo Agent pid 2807;
Run Code Online (Sandbox Code Playgroud)
如果我运行,ps aux | grep ssh我可以看到它正在运行。
然后我尝试运行ssh-add以添加我的密钥密码,我得到以下信息:
Could not open a connection to your authentication agent.
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
Sté*_*las 281
你的 shell 是用来评估 shell 代码输出的ssh-agent。运行这个:
eval "$(ssh-agent)"
Run Code Online (Sandbox Code Playgroud)
或者,如果您已经启动了 ssh-agent,请将其复制粘贴到您的 shell 提示符(假设您正在运行类似 Bourne 的 shell)。
ssh命令需要知道如何与 对话ssh-agent,他们从SSH_AUTH_SOCK环境变量中知道这一点。
小智 37
试试这个:
$ ssh-agent /bin/sh
$ ssh-add $yourkey
Run Code Online (Sandbox Code Playgroud)
xaa*_*xaa 15
这个问题在Stackoverflow上也有很好的介绍。
eval `ssh-agent -s`
ssh-add
Run Code Online (Sandbox Code Playgroud)
如果使用 csh 作为 shell ( FreeBSD PI ),这可以工作:
eval `ssh-agent -c`
Run Code Online (Sandbox Code Playgroud)
接下来,您只需要执行以下操作:
ssh-add ~/.ssh/id_rsa
Run Code Online (Sandbox Code Playgroud)
您还可以使用以下语法:
ssh-agent sh -c 'ssh-add && echo Do some stuff here.'
Run Code Online (Sandbox Code Playgroud)