qa9*_*a95 50 ssh cmd bitbucket ssh-keys git-clone
我正在尝试将生成的密钥添加到 ssh 代理。下面是我的步骤
C:\repo>ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\mante1/.ssh/id_rsa):C:\repo\key
Run Code Online (Sandbox Code Playgroud)
生成密钥后,我将启动 ssh 代理并添加它
C:\repo>start-ssh-agent
Found ssh-agent at 13460
Found ssh-agent socket at /tmp/ssh-vKzdrs37QYVK/agent.821
C:\repo>ssh-add ~/.ssh/id_rsa
Error connecting to agent: No such file or directory
Run Code Online (Sandbox Code Playgroud)
ash*_*887 35
Get-Service ssh-agent | Set-Service -StartupType Automatic
# By default the ssh-agent service is disabled. Configure it to start automatically.
# Make sure you're running as an Administrator.
Run Code Online (Sandbox Code Playgroud)
Start-Service ssh-agent
# Start the service
Run Code Online (Sandbox Code Playgroud)
Get-Service ssh-agent
# This should return a status of Running
Run Code Online (Sandbox Code Playgroud)
ssh-add <complete-key-path-here>
Key Path Example: C:\Users\so\.ssh/key-name
# Now load your key files into ssh-agent
Run Code Online (Sandbox Code Playgroud)
原始来源:https ://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_keymanagement
Pra*_*shi 21
这个问题可能是因为你有两种类型的 ssh-agent.exe ,你可以在任务管理器中看到它们,一种 ssh-agent 来自 git,另一种来自 OpenSSH。
使固定
C:\repo\key 这应该是您的工作目录),然后运行start-ssh-agent将自动将您的私钥添加到 ssh,并且您不需要该ssh-add命令。小鬼
start-ssh-agent将使用 git 中的 sshstart ssh-agent将使用 OpenSSH 中的 ssh因此,您使用的 ssh 版本与添加/生成的密钥之间可能存在不一致
Von*_*onC 13
如果您已在 生成密钥C:\repo\key,那么您需要的密钥ssh-add是... C:\repo\key,而不是 ~/.ssh/id_rsa
C:\repo>ssh-add C:\repo\key
Run Code Online (Sandbox Code Playgroud)
那行得通。
Let*_*III 12
尝试输入:
ssh-agent bash
Run Code Online (Sandbox Code Playgroud)
然后执行:
ssh-add...
Run Code Online (Sandbox Code Playgroud)