Thi*_*his 3 ssh github public-key private-key
我已将 OpenSSH 配置为在登录 github 时使用特定密钥....
[mpenning@mudslide .ssh]$ pwd
/home/mpenning/.ssh
[mpenning@mudslide .ssh]$ ls -la | grep config
-rw-r--r-- 1 mpenning mpenning 473 Jan 23 09:49 config
[mpenning@mudslide .ssh]$ head -n 4 config
Host gh
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_github
[mpenning@mudslide .ssh]$
Run Code Online (Sandbox Code Playgroud)
但是,当我在没有在 CLI 上显式调用 github 的私钥的情况下 ssh 到 github 时,身份验证失败:
[mpenning@mudslide .ssh]$ ssh -F ./config git@github.com
Permission denied (publickey). ^^^^^^^^ This used to work
[mpenning@mudslide .ssh]$
Run Code Online (Sandbox Code Playgroud)
我可以强制它工作的唯一方法是在我 ssh 时显式调用私钥......
[mpenning@mudslide .ssh]$ ls -la | grep github
-r-------- 1 mpenning mpenning 3243 Nov 24 2016 id_rsa_github
-rw-r--r-- 1 mpenning mpenning 743 Nov 24 2016 id_rsa_github.pub
[mpenning@mudslide .ssh]$ ssh -i ./id_rsa_github git@github.com
PTY allocation request failed on channel 0
Hi mpenning! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
[mpenning@mudslide .ssh]$
Run Code Online (Sandbox Code Playgroud)
我的config文件昨天有效......我没有改变任何东西。该config文件已指向正确的私钥。
突然,ssh 似乎忽略了我的 github 配置。它甚至从不尝试正确的私钥......
[mpenning@mudslide .ssh]$ ssh -v git@github.com 2>&1 | grep github
debug1: Connecting to github.com [192.30.253.113] port 22.
debug1: Host 'github.com' is known and matches the RSA host key.
[mpenning@mudslide .ssh]$
Run Code Online (Sandbox Code Playgroud)
显然这是有效的,但我不应该使用 -i ...
[mpenning@mudslide .ssh]$ ssh -i id_rsa_github -v git@github.com 2>&1 | grep github
debug1: Connecting to github.com [192.30.253.113] port 22.
debug1: identity file id_rsa_github type 1
debug1: identity file id_rsa_github-cert type -1
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Offering RSA public key: id_rsa_github
Authenticated to github.com ([192.30.253.113]:22).
Connection to github.com closed.
[mpenning@mudslide .ssh]$
Run Code Online (Sandbox Code Playgroud)
我的问题:
您不是在调用连接到您在配置中定义的主机。
ssh gh不使用ssh .... git@github.com
但为什么?- 见下文:
[mpenning@mudslide .ssh]$ ssh -F ./config git@github.com 权限被拒绝(公钥)。^^^^^^^^ 这曾经有效
我不认为它曾经做过(你用历史检查过吗?)。我想你用过ssh -F ./config gh
您gh在配置中定义了主机:
Host gh
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_github
Run Code Online (Sandbox Code Playgroud)
所以你应该简单地调用ssh gh. 如果您想覆盖配置中的内容,您可以传递其他参数,例如,如果您想使用不同的用户,但是因为您已经设置了所有必需的变量,您应该只使用 Host 变量,仅此而已。
-F ./config老实说,您甚至不需要通过。
| 归档时间: |
|
| 查看次数: |
3383 次 |
| 最近记录: |