没有发现SSH密钥从Windowslogin到CentOS 5.5(Cygwin)

使用公共密钥身份validationlogin到运行CentOS 5.5的VPS时遇到困难。 我可以使用密码authenticationlogin到标准用户帐户和root帐户。 我使用的是Windows和Cygwin,所有的Cygwin和Windows的东西几个月来一直工作得很好; 我相信这个问题是服务器端。

我用ssh-keygen创build了一个id_rsa私钥和一个id_rsa.pub公钥。 我已经复制到服务器上的用户目录,并完成cat id_rsa.pub >> authorized_keys 。 我的/home/myuser/.ssh目录设置为700,authorized_keys文件设置为600。

login我的系统时报告以下(-vvv):

 Next authentication method: publickey Offering RSA public key /.ssh/id_rsa send_pubkey_test we sent a publickey packet, wait for reply Authentications that can continue: publickey,password 

然后问我一个密码。 从我的服务器的/ var / log / auth文件我有以下相关的公钥进程

 sshd[28249]: input_userauth_request: try method publickey sshd[28249]: test whether pkalg/pkblob are acceptable sshd[28249]: mm_key_allowed entering sshd[28249]: mm_request_send entering: type 21 sshd[28249]: mm_key_allowed: waiting for MONITOR_ANS_KEYALLOWED sshd[28249]: mm_request_receive_expect entering: type 22 sshd[28248]: monitor_read: checking request 21 sshd[28249]: mm_request_receive entering sshd[28248]: mm_answer_keyallowed entering sshd[28248]: mm_answer_keyallowed: key_from_blob: 0x2b6ea1049910 sshd[28248]: temporarily_use_uid: 10022/10022 (e=0/0) sshd[28248]: trying public key file /home/myuser/.ssh/authorized_keys sshd[28248]: secure_filename: checking '/home/myuser/.ssh' sshd[28248]: secure_filename: checking '/home/myuser' sshd[28248]: secure_filename: terminating check at '/home/myuser' sshd[28248]: restore_uid: 0/0 sshd[28248]: key not found sshd[28248]: temporarily_use_uid: 10022/10022 (e=0/0) sshd[28248]: trying public key file /home/myuser/.ssh/authorized_keys sshd[28248]: secure_filename: checking '/home/myuser/.ssh' sshd[28248]: secure_filename: checking '/home/myuser' sshd[28248]: secure_filename: terminating check at '/home/myuser ' sshd[28248]: restore_uid: 0/0 sshd[28248]: key not found sshd[28248]: Normalising mapped IPv4 in IPv6 address sshd[28248]: Failed publickey for myuser from 87.115.220.187 port 59636 ssh2 

就好像它找不到authorized_keys文件。 但是,命令nano /home/myuser/.ssh/authorized_keys打开文件没有问题。

从/ etc / ssh / sshd_config:

 PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys 

有些人报告说,authorized_keys文件中的换行符可能会导致问题,所以我确定没有(反正只有一个键)。 该文件以ssh-rsa开头,然后是长键,最后是一个空格, M1ke@M1ke-PC

任何人有任何想法?

如果你真的做了这个cat id_rsa.pub < authorized_keys那么你的authorized_keys文件将不会包含一个公钥来匹配你使用的私钥,所以ssh回到了密码authentication。 解决这个问题

 cat id_rsa.pub >>authorized_keys 

将新的公钥添加到您的authorized_keys。

SELinux是否启用? 如果是,则该文件需要设置上下文。