我创建了~/.ssh/config
文件:
Host github.com-xxx
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_xxx
当我运行ssh github.com-xxx
时,我收到错误:
Permission denied (publickey).
(我还为其他服务器定义了其他~/.ssh/id_rsa
个文件。)
当我添加-v
时,日志如下:
OpenSSH_6.9p1, LibreSSL 2.1.8
debug1: Reading configuration data /Users/xxx/.ssh/config
debug1: /Users/xxx/.ssh/config line 17: Applying options for github.com-xxx
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to github.com [192.30.253.113] port 22.
debug1: Connection established.
debug1: identity file /Users/xxx/.ssh/id_rsa_xxx type 1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/xxx/.ssh/id_rsa_xxx-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9
debug1: Remote protocol version 2.0, remote software version libssh_0.7.0
debug1: no match: libssh_0.7.0
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client chacha20-poly1305@openssh.com <implicit> none
debug1: kex: client->server chacha20-poly1305@openssh.com <implicit> none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /Users/xxx/.ssh/known_hosts:1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/xxx/.ssh/id_rsa_xxx
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).
当我尝试ssh git@github.com
时,它会成功:
Hi OTHER_USER! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
OTHER_USER
是我创建~/.ssh/id_rsa
文件的用户。