Linux SSH 错误解析(Capistrano 的cap 访问错误 Permission )

[email protected]出现

Permissiondenied(publickey,gssapi-keyex,gssapi-with-mic,password).

错误

运行状况如下:

OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.18.133 [192.168.18.133] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/identity type -1
debug1: identity file /root/.ssh/identity-cert type -1
debug1: identity file /root/.ssh/id_rsa type 1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '192.168.18.133' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:2
debug1: ssh_rsa_verify: signature correct
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,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
Credentials cache file '/tmp/krb5cc_0' not found

debug1: Unspecified GSS failure.  Minor code may provide more information
Credentials cache file '/tmp/krb5cc_0' not found

debug1: Unspecified GSS failure.  Minor code may provide more information


debug1: Unspecified GSS failure.  Minor code may provide more information
Credentials cache file '/tmp/krb5cc_0' not found

debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/identity
debug1: Offering public key: /root/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: No more authentication methods to try.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).

解决办法:

1、查看我的密钥,ls~/.ssh/:

[[email protected]]#ls~/.ssh/

authorized_keysid_rsaid_rsa.pubknown_hosts

2、发现我的id_rsa文件我命令为id_rsa, 所以根本没有使用它。

同时可以使用如下命令查看密钥列表:

  ssh-add-l

[[email protected]]#ssh-add-l

Theagenthasnoidentities.

3、上面命令的密钥列表为空,所以要添加我的密钥,使用命令:

 [[email protected]]#ssh-addid_rsa

Identityadded:id_rsa(id_rsa)

4、再次查看,如下,添加成功:

[[email protected]]#ssh-add-l

2048c6:60:c6:f8:29:25:0b:87:27:9c:37:5e:77:ec:05:e4id_rsa(RSA)

5、再使用[email protected]测试连接,可以看到验证通过:

[[email protected]]#[email protected]

OpenSSH_5.3p1,OpenSSL1.0.1e-fips11Feb2013

debug1:Readingconfigurationdata/etc/ssh/ssh_config

debug1:Applyingoptionsfor*

debug1:Connectingto192.168.18.133[192.168.18.133]port22.

debug1:Connectionestablished.

debug1:permanently_set_uid:0/0

debug1:identityfile/root/.ssh/identitytype-1

debug1:identityfile/root/.ssh/identity-certtype-1

debug1:identityfile/root/.ssh/id_rsatype1

debug1:identityfile/root/.ssh/id_rsa-certtype-1

debug1:identityfile/root/.ssh/id_dsatype-1

debug1:identityfile/root/.ssh/id_dsa-certtype-1

debug1:identityfile/root/.ssh/id_ecdsatype-1

debug1:identityfile/root/.ssh/id_ecdsa-certtype-1

debug1:Remoteprotocolversion2.0,remotesoftwareversionOpenSSH_5.3

debug1:match:OpenSSH_5.3patOpenSSH*

debug1:Enablingcompatibilitymodeforprotocol2.0

debug1:LocalversionstringSSH-2.0-OpenSSH_5.3

debug1:SSH2_MSG_KEXINITsent

debug1:SSH2_MSG_KEXINITreceived

debug1:kex:server->clientaes128-ctrhmac-md5none

debug1:kex:client->serveraes128-ctrhmac-md5none

debug1:SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192)sent

debug1:expectingSSH2_MSG_KEX_DH_GEX_GROUP

debug1:SSH2_MSG_KEX_DH_GEX_INITsent

debug1:expectingSSH2_MSG_KEX_DH_GEX_REPLY

debug1:Host'192.168.18.133'isknownandmatchestheRSAhostkey.

debug1:Foundkeyin/root/.ssh/known_hosts:2

debug1:ssh_rsa_verify:signaturecorrect

debug1:SSH2_MSG_NEWKEYSsent

debug1:expectingSSH2_MSG_NEWKEYS

debug1:SSH2_MSG_NEWKEYSreceived

debug1:SSH2_MSG_SERVICE_REQUESTsent

debug1:SSH2_MSG_SERVICE_ACCEPTreceived

debug1:Authenticationsthatcancontinue:publickey,gssapi-keyex,gssapi-with-mic

debug1:Nextauthenticationmethod:gssapi-keyex

debug1:NovalidKeyexchangecontext

debug1:Nextauthenticationmethod:gssapi-with-mic

debug1:UnspecifiedGSSfailure.Minorcodemayprovidemoreinformation

Credentialscachefile'/tmp/krb5cc_0'notfound

debug1:UnspecifiedGSSfailure.Minorcodemayprovidemoreinformation

Credentialscachefile'/tmp/krb5cc_0'notfound

debug1:UnspecifiedGSSfailure.Minorcodemayprovidemoreinformation

debug1:UnspecifiedGSSfailure.Minorcodemayprovidemoreinformation

Credentialscachefile'/tmp/krb5cc_0'notfound

debug1:Nextauthenticationmethod:publickey

debug1:Offeringpublickey:id_rsa

debug1:Serveracceptskey:pkalgssh-rsablen277

debug1:Authenticationsucceeded(publickey).

debug1:channel0:new[client-session]

debug1:[email protected]

debug1:Enteringinteractivesession.

debug1:Sendingenvironment.

debug1:SendingenvLANG=zh_CN.UTF-8

6.测试成功