2014-12-04 102 views
1

在一臺運行在CentOS v6.2上的同一臺目標機器上,我從我的Macbook和另一臺Ubuntu機器上執行了相同的一套程序。 Macbook ssh無需登錄即可正常工作,但Ubuntu服務器仍然無法連接到目標機器的無密碼。以下是我所做的:仍然要求在ssh登錄時輸入密碼

KEYNAME=~/.ssh/foo_key 
# generate a new key 
ssh-keygen -t rsa -f ${KEYNAME} 
# fix permissions 
chmod 600 ${KEYNAME}.pub ${KEYNAME} 
# add key 
eval `ssh-agent -s` 
eval "$(ssh-agent)" 
ssh-add ${KEYNAME} 
# copy key to target machine foo 
cat ${KEYNAME}.pub | ssh foo "cat - >> ~/.ssh/authorized_keys" 
cat ${KEYNAME}.pub | ssh foo "cat - >> ~/.ssh/authorized_keys2" 

2-然後我在Macbook和Ubuntu中的〜/ .ssh/config文件中添加了keyname。

3我確保將目標機器~/.ssh~/.ssh/authorized*權限修復爲700/750。

  • 其他一些信息:

    Ubuntu的協議版本號爲:OpenSSH_5.9p1 Debian-5ubuntu1.1, OpenSSL 1.0.1 14 Mar 2012

    的Macbook協議版本號爲:OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011

    目標的CentOS V6.2協議版本號爲:OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013

這是的結果:

OpenSSH_5.9p1 Debian-5ubuntu1.1, OpenSSL 1.0.1 14 Mar 2012 
debug1: Reading configuration data /home/ashouri/.ssh/config 
debug1: /home/ashouri/.ssh/config line 1: Applying options for * 
debug1: /home/ashouri/.ssh/config line 5: Applying options for eecis 
debug1: Reading configuration data /etc/ssh/ssh_config 
debug1: /etc/ssh/ssh_config line 19: Applying options for * 
debug1: Connecting to hoek.eecis.udel.edu [128.4.31.39] port 22. 
debug1: Connection established. 
debug1: identity file /home/ashouri/.ssh/cavazos_lab.pub type 1 
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048 
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048 
debug1: identity file /home/ashouri/.ssh/cavazos_lab.pub-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.9p1 Debian-5ubuntu1.1 
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: Server host key: RSA d5:d6:53:4c:41:81:3b:28:41:ef:8b:97:d9:19:3b:dd 
debug1: Host 'hoek.eecis.udel.edu' is known and matches the RSA host key. 
debug1: Found key in /home/ashouri/.ssh/known_hosts:7 
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,gssapi-keyex,gssapi-with-mic,password,hostbased 
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_1005' not found 

debug1: Unspecified GSS failure. Minor code may provide more information 
Credentials cache file '/tmp/krb5cc_1005' 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_1005' not found 

debug1: Next authentication method: publickey 
debug1: Offering RSA public key: /home/ashouri/.ssh/cavazos_lab.pub 
debug1: key_parse_private_pem: PEM_read_PrivateKey failed 
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password,hostbased 
debug1: Next authentication method: password 

任何人都可以指導我爲什麼會發生這種情況?

+1

當ssh -vvv失敗時會說什麼? – 2014-12-04 21:16:48

+0

看到我更新的問題:) – Amir 2014-12-04 21:17:44

+1

我通常發現OpenSSH生成的日誌在診斷這些問題時最有用。 – 2014-12-04 21:19:26

回答

1

上網衝浪一個小時後,我找到一個帖子Here,其中說明了解決問題的竅門;只需要將〜/ .ssh/config中的公鑰文件的引用作爲標識刪除,而不是指向私鑰。 (只需從行中刪除.pub段)。就這樣!

相關問題