与公共RSA密钥的SSH连接

我在我们的法人networking中有下一个configuration:

客户:[email protected]

的/ etc / SSH / ssh_config中:

Host * SendEnv LANG LC_* HashKnownHosts yes GSSAPIAuthentication yes GSSAPIDelegateCredentials no 

文件权限:

 artur@lothlorien:~$ ls -la ~/.ssh | grep "authorized_keys" -rw------- 1 artur artur 407 чер 4 10:11 authorized_keys artur@lothlorien:~$ ls -la ~ | grep ".ssh" drwx------ 2 artur artur 4096 чер 4 10:33 .ssh 

更多:

  • 服务器添加到~/.ssh/known_hosts文件的内容
  • ~/.ssh/id_rsa.pub附加到[email protected]用户的主目录

的/ proc /版本:

Linux version 3.5.0-32-generic (buildd@akateko) (gcc version 4.7.2 (Ubuntu/Linaro 4.7.2-2ubuntu1) ) #53-Ubuntu SMP Wed May 29 20:23:04 UTC 2013

服务器:[email protected]

  • /etc/ssh/ssh_config[email protected]相同
  • ~/.ssh/authorized_keys文件权限600
  • ~/.ssh目录权限为700
  • isd_programmer@server> cat ~/.ssh/authorized_keys拥有[email protected]的公钥

的/ proc /版本:

Linux version 2.6.38-16-server (buildd@batsu) (gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4) ) #67-Ubuntu SMP Thu Sep 6 18:15:24 UTC 2012

连接:

 artur@lothlorien:~$ ssh [email protected] -v OpenSSH_6.0p1 Debian-3ubuntu1, OpenSSL 1.0.1c 10 May 2012 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug1: Connecting to server.isd [192.168.1.201] port 22. debug1: Connection established. debug1: identity file /home/artur/.ssh/id_rsa 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/artur/.ssh/id_rsa-cert type -1 debug1: identity file /home/artur/.ssh/id_dsa type -1 debug1: identity file /home/artur/.ssh/id_dsa-cert type -1 debug1: identity file /home/artur/.ssh/id_ecdsa type -1 debug1: identity file /home/artur/.ssh/id_ecdsa-cert type -1 debug1: Remote protocol version 2.0, remote software version OpenSSH_5.8p1 Debian-1ubuntu3 debug1: match: OpenSSH_5.8p1 Debian-1ubuntu3 pat OpenSSH_5* debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.0p1 Debian-3ubuntu1 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: sending SSH2_MSG_KEX_ECDH_INIT debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ECDSA bf:55:f2:57:f1:8e:c9:cf:a1:3f:f8:d0:81:6b:d4:7d debug1: Host 'server.isd' is known and matches the ECDSA host key. debug1: Found key in /home/artur/.ssh/known_hosts:1 debug1: ssh_ecdsa_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,password debug1: Next authentication method: publickey debug1: Offering RSA public key: /home/artur/.ssh/id_rsa debug1: Authentications that can continue: publickey,password debug1: Trying private key: /home/artur/.ssh/id_dsa debug1: Trying private key: /home/artur/.ssh/id_ecdsa debug1: Next authentication method: password [email protected]'s password: 

至于我看起来像所有configurationcorect,但为什么我得到提示input密码?

UPD(2013-06-07 07:05:12):sudo less -500 /var/log/auth.log发现sudo less -500 /var/log/auth.log

 Authentication refused: bad ownership or modes for directory /var/www 

/var/www[email protected]主目录

想到几个原因:

  • 服务器被configuration为不允许密钥validation
  • 客户端主机不在 hosts.allow中,或者在hosts.deny中
  • 客户端用户不是允许的ssh用户
  • 权限阻止读取authorized_keys (检查所有父目录)
  • 权限对于authorized_keys来说太宽泛了(文件和所有父目录不能被root和所需用户以外的任何人写入)。
  • 键不匹配

有更多的原因,这些是马上想到的。 记住这个网站是关于解决所有人的问题,而不是定制你的特定服务器的答案。

自己解决了这个问题。 /var/www有权限:

 drwxrwxr-x 112 isd_programmer www-data 4096 2013-06-07 10:24 www 

我无法更改权限,因为www-data组中有更多的用户需要访问此文件夹。 但是/etc/ssh/sshd_config StrictModes被设置为yes (默认) 。 所以我把它改为no,然后重新启动sshd: sudo restart ssh

您错过了Client: ([email protected])私钥Client: ([email protected])

[email protected] ,将id_rsa放在/home/artur/.ssh/以供SSH使用。