我想使用多个私钥连接到不同的服务器或同一服务器的不同部分(我的用途是服务器的系统管理,Git的管理,以及同一服务器内的正常Git使用).我试过简单地将id_rsa文件中的密钥堆叠起来无济于事.
显然,一种直接的方法是使用该命令
ssh -i <key location> login@server.example.com
Run Code Online (Sandbox Code Playgroud)
这非常麻烦.
关于如何更轻松地做这件事的任何建议?
我想使用配置来设置sshCommand而不是环境变量。但不起作用这是发生了什么
? GIT_SSH_COMMAND='ssh -i /var/www/level2.lu/www/git_id_rsa -F /dev/null' git ls-remote
From git@github.com:syn2cat/Level2.lu.git
fcaa5a2e63499568dd916e7b18f950b311781bd0 HEAD
fcaa5a2e63499568dd916e7b18f950b311781bd0 refs/heads/master
a542061a64d3698d5da54d63456b26932fe549a2 refs/pull/1/head
? git config core.sshcommand
ssh -i /var/www/level2.lu/www/git_id_rsa -F /dev/null
? git ls-remote
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
并进行调试,它不使用core.sshCommand中的值
? GIT_TRACE=1 git ls-remote
13:46:15.366401 git.c:344 trace: built-in: git 'ls-remote'
13:46:15.366564 run-command.c:334 trace: run_command: 'ssh' 'git@github.com' 'git-upload-pack '\''syn2cat/Level2.lu.git'\'''
Run Code Online (Sandbox Code Playgroud)
版本号
? lsb_release -a
No LSB modules are available. …Run Code Online (Sandbox Code Playgroud)