【发布时间】:2025-12-12 13:50:02
【问题描述】:
我正在编写我的ssh config 文件并希望发送具有选定密钥的代理。没有密钥可以离开我的本地机器,并且发送的代理可能只有必要的密钥。所有密钥都需要密码。我不想按顺序多次输入密码,例如访问server 时,但不介意在我访问机器时再次输入。下面显示了我想如何连接到不同的服务器:
local [--> git (git key)]
local --> frontend (compute key)
local --> frontend (compute key) --> server (compute key)
local --> frontend (compute key) [--> git] (git key)
local --> otherserver (passwort & app)
local --> otherserver (passwort & app) [--> git] (git key)
local --> somwherelse (else key)
我的本地ssh config:
Host server
HostName server.compute.net
User user1
AddKeysToAgent yes
IdentitiesOnly yes
IdentityFile ~/.ssh/id_ed25519_compute
IdentityFile ~/.ssh/id_ed25519_git
ProxyJump frontend
Host frontend
HostName frontend.compute.net
User user1
AddKeysToAgent yes
IdentitiesOnly yes
IdentityFile ~/.ssh/id_ed25519_compute
IdentityFile ~/.ssh/id_ed25519_git
Host otherserver
Hostname otherserver.com
User user2
AddKeysToAgent yes
IdentitiesOnly yes
IdentityFile ~/.ssh/id_ed25519_git
Host somwhereelse
Hostname somewhereelse.com
User user3
AddKeysToAgent yes
IdentitiesOnly yes
IdentityFile ~/.ssh/id_ed25519_else
Host git
Hostname git.url.com
IdentitiesOnly yes
IdentityFile ~/.ssh/id_ed25519_git
但是当我在frontend 上尝试git pull 时,我得到:
git@git.url.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
在本地,git 访问有效。在登录frontend 之前,我确保代理正在运行。我做错了什么?
【问题讨论】:
-
您是否允许代理转发,以便
frontend上的ssh进程可以访问在local上运行的代理? -
可能不会。我与
ssh frontend联系。我需要做什么才能允许代理转发? -
您可以在运行
ssh时使用-X选项,也可以在配置文件中使用ForwardAgent选项为特定主机自动启用它。 -
将
ForwardAgent添加到config有效,ssh -X无效,但ssh -A有效。如果你写一个简短的答案,我会接受,谢谢。 -
很抱歉;
-X是 X11 转发。我的手册页浏览技巧正在衰退。
标签: ssh config ssh-keys ssh-config