SSH 密钥不适用于全新 linux 安装
SSH Key does not work on a fresh linux install
我最近重新安装了我的 OS (Mint 17.1) 并想使用我的 ssh 密钥连接到 git。到目前为止,我已经在很多地方使用过这把钥匙,没有任何问题。关于这个问题有很多答案,但 none 到目前为止对我有帮助。
.ssh 目录有 0700 权限
所以我得到的输出是这样的:
ssh -vT git@github.com
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /home/herod/.ssh/config
debug1: /home/herod/.ssh/config line 1: Applying options for *
debug1: /home/herod/.ssh/config line 9: Applying options for github.com
debug1: /home/herod/.ssh/config line 14: Applying options for github.com
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to github.com [192.30.252.128] port 22.
debug1: Connection established.
debug1: identity file /home/herod/.ssh/xxxx/id_rsa.pub type 1
debug1: identity file /home/herod/.ssh/xxxx/id_rsa.pub-cert type -1
debug1: identity file /home/herod/.ssh/xxxx2222/id_rsa.pub type 1
debug1: identity file /home/herod/.ssh/xxxx2222/id_rsa.pub-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: Remote protocol version 2.0, remote software version libssh-0.6.0
debug1: no match: libssh-0.6.0
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-sha1 none
debug1: kex: client->server aes128-ctr hmac-sha1 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: RSA 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /home/herod/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
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: /home/herod/.ssh/xxxx/id_rsa.pub
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: key_parse_private2: missing begin marker
debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
Enter passphrase for key '/home/herod/.ssh/xxxx/id_rsa.pub':
debug1: key_parse_private2: missing begin marker
debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
这对我有用(答案来自 here):
"For me since the key itself was encrypted, I followed the following
steps:
Start ssh-agent:
$ ssh-agent bash
Add standard identity key to the key manager:
$ ssh-add
If you want to add a different key, then:
$ ssh-add /location/of/key
To inspect at any time, the list of currently loaded keys:
$ ssh-add -l More details can be obtained from this link"
作为对@Kenster 评论和此处解决方案的补充,当您添加密钥时,您必须添加私钥
$ ssh-add /location/of/key (ex ssh-add .ssh/folder/id_rsa)
而不是
$ ssh-add /location/of/key.pub (ex ssh-add .ssh/folder/id_rsa.pub)
我最近重新安装了我的 OS (Mint 17.1) 并想使用我的 ssh 密钥连接到 git。到目前为止,我已经在很多地方使用过这把钥匙,没有任何问题。关于这个问题有很多答案,但 none 到目前为止对我有帮助。
.ssh 目录有 0700 权限
所以我得到的输出是这样的:
ssh -vT git@github.com
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /home/herod/.ssh/config
debug1: /home/herod/.ssh/config line 1: Applying options for *
debug1: /home/herod/.ssh/config line 9: Applying options for github.com
debug1: /home/herod/.ssh/config line 14: Applying options for github.com
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to github.com [192.30.252.128] port 22.
debug1: Connection established.
debug1: identity file /home/herod/.ssh/xxxx/id_rsa.pub type 1
debug1: identity file /home/herod/.ssh/xxxx/id_rsa.pub-cert type -1
debug1: identity file /home/herod/.ssh/xxxx2222/id_rsa.pub type 1
debug1: identity file /home/herod/.ssh/xxxx2222/id_rsa.pub-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: Remote protocol version 2.0, remote software version libssh-0.6.0
debug1: no match: libssh-0.6.0
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-sha1 none
debug1: kex: client->server aes128-ctr hmac-sha1 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: RSA 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /home/herod/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
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: /home/herod/.ssh/xxxx/id_rsa.pub
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: key_parse_private2: missing begin marker
debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
Enter passphrase for key '/home/herod/.ssh/xxxx/id_rsa.pub':
debug1: key_parse_private2: missing begin marker
debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
这对我有用(答案来自 here):
"For me since the key itself was encrypted, I followed the following steps:
Start ssh-agent:
$ ssh-agent bash
Add standard identity key to the key manager:
$ ssh-add
If you want to add a different key, then:
$ ssh-add /location/of/key
To inspect at any time, the list of currently loaded keys:
$ ssh-add -l More details can be obtained from this link"
作为对@Kenster 评论和此处解决方案的补充,当您添加密钥时,您必须添加私钥
$ ssh-add /location/of/key (ex ssh-add .ssh/folder/id_rsa)
而不是
$ ssh-add /location/of/key.pub (ex ssh-add .ssh/folder/id_rsa.pub)