2010-08-30 126 views
3

我正在嘗試使用RSA密鑰來設置SSH連接,而無需使用密碼到許多服務器。它適用於大多數人,但一個給我一些麻煩。使用RSA密鑰的SSH連接保持詢問密碼

最常見的問題我已經在過去發現是在遠程主機上的.ssh或authorized_keys的權限問題,但在這裏,他們似乎是正確的,就像這樣:

drwx------ ~/.ssh 
-rw-r--r-- ~/.ssh/authorized_keys 

下面是SSH的輸出 - -v命令到該服務器(我只是改變主機名和IP):

Sun_SSH_1.1.3, SSH protocols 1.5/2.0, OpenSSL 0x0090704f 
debug1: Reading configuration data /etc/ssh/ssh_config 
debug1: Rhosts Authentication disabled, originating port will not be trusted. 
debug1: ssh_connect: needpriv 0 
debug1: Connecting to myhost.mydomain.com [123.123.123.123] port 22. 
debug1: Connection established. 
debug1: identity file /export/home/webdev1/.ssh/identity type -1 
debug1: identity file /export/home/webdev1/.ssh/id_rsa type 1 
debug1: identity file /export/home/webdev1/.ssh/id_dsa type -1 
debug1: Remote protocol version 1.5, remote software version 1.2.31 
debug1: match: 1.2.31 pat 1.2.1*,1.2.2*,1.2.3* 
debug1: Local version string SSH-1.5-Sun_SSH_1.1.3 
debug1: Waiting for server public key. 
debug1: Received server public key (768 bits) and host key (1024 bits). 
debug1: Host 'myhost.mydomain.com' is known and matches the RSA1 host key. 
debug1: Found key in /export/home/webdev1/.ssh/known_hosts:6 
debug1: Encryption type: 3des 
debug1: Sent encrypted session key. 
debug1: cipher_init: set keylen (16 -> 32) 
debug1: cipher_init: set keylen (16 -> 32) 
debug1: Installing crc compensation attack detector. 
debug1: Received encrypted confirmation. 
debug1: Doing password authentication. 

我懷疑這可能是由於SSH版本。另一臺服務器工作給我以下輸出(遠程協議版本2.0而不是1.5):

debug1: Remote protocol version 2.0, remote software version Sun_SSH_1.1.3 
debug1: match: Sun_SSH_1.1.3 pat Sun_SSH_1.1.* 
debug1: Enabling compatibility mode for protocol 2.0 
debug1: Local version string SSH-2.0-Sun_SSH_1.1.3 

任何線索? 感謝您的幫助。

回答

1

服務器可能被配置爲拒絕基於公鑰的無密碼驗證。我不知道Sun_SSH,但是在OpenSSH(Linux/* BSD系統上最流行的SSH實現)中,這是改變/etc/ssh/sshd_config中的某些設置(V1協議的選項RSAAuthentication,第2版的選項PubkeyAuthentication)的問題。

+0

感謝您提供此信息。我沒有root權限來調查Sun_SSH的配置,但這確實是問題所在。我會盡力讓系統管理員參與其中。 – Damien 2010-09-02 18:50:56

+0

'/ etc/ssh/ssd_config'應該是'/ etc/ssh/sshd_config'(或者可能是'/ etc/ssh/ssh_config') – 2013-08-29 20:56:40

1

嘗試只

chmod -R 600 ~/.ssh/

也許組/全局讀權限引起的問題。

+0

我試過了但沒有幫助。無論如何感謝您的嘗試。 – Damien 2010-08-31 17:18:16

+0

這幫助了我,並將正確的id_rsa和id_rsa.pub文件複製到〜/ .ssh /文件夾 – despina 2014-07-11 08:30:36

3
chmod 744 ~/.ssh/authorized_keys 

適合我。

+4

「644」更好......不需要執行。而且,.ssh目錄本身必須以「700」作爲保證。但+1指向我在正確的方向 – 2012-11-05 14:18:46

1

也許你的用戶被鎖定在unix盒子上。如果您通常使用自己的帳戶登錄,然後「成爲」功能用戶,如果該用戶啓用了「密碼登錄」功能,但您未使用該功能,則可能會被鎖定(例如,密碼已過期)。 Howerver,即使是掛鎖,它也不會阻止你使用「be」命令來sudo它,但它會明確地防止任何ssh登錄,即使這些密鑰是可信的。

+0

好的,謝謝Olivier,不幸的是我沒有再訪問這些機器,所以我不能驗證是否是這種情況。但如果它再次發生在我身上,我會檢查這一點; o) – Damien 2012-06-19 16:14:23

2

請確保您的主目錄(/export/home/webdev1)也具有700權限。