PubKey身份validation不起作用

我试图设置我的Mac和CentOS dedi服务器之间的PubKey身份validation,但有些东西是…

以下是我采取的步骤:

ssh-keygen -t rsa 

然后

  chmod 700 .ssh/ && chmod 600 .ssh/* 

然后

  scp id_rsa.pub root@dedi:~/.ssh/authorized_keys 

然后(抱歉,所有这些“那么”)

  ssh root@dedi 

你知道什么? 我得到提示input密码。

有任何想法吗? 谢谢!

编辑 :这是ssh -v root@dedi的输出:

  SH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011 debug1: Reading configuration data /etc/ssh_config debug1: /etc/ssh_config line 20: Applying options for dedi debug1: Connecting to dediserversdomain.com.au.co.net.org.bz [198.100.145.168] port 22. debug1: Connection established. debug1: identity file /Users/someone/.ssh/id_rsa,~/.ssh/id_dsa type -1 debug1: identity file /Users/someone/.ssh/id_rsa,~/.ssh/id_dsa-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.2 debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3 debug1: match: OpenSSH_5.3 pat OpenSSH_5* 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 (my rsa key) debug1: Host 'dediserversdomain.com.au.co.net.org.bz' is known and matches the RSA host key. debug1: Found key in /Users/someone/.ssh/known_hosts:1 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 debug1: Next authentication method: publickey debug1: Trying private key: /Users/someone/.ssh/id_rsa,~/.ssh/id_dsa debug1: Next authentication method: password [email protected]'s password: 

编辑 :输出stat .sshstat .ssh/*从我的dedi:

  File: `.ssh' Size: 4096 Blocks: 8 IO Block: 4096 directory Device: 801h/2049d Inode: 1175048 Links: 2 Access: (0700/drwx------) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2014-09-21 11:21:43.000000000 -0400 Modify: 2014-09-21 10:52:26.000000000 -0400 Change: 2014-09-21 11:21:49.000000000 -0400 File: `.ssh/authorized_keys' Size: 411 Blocks: 8 IO Block: 4096 regular file Device: 801h/2049d Inode: 1175045 Links: 1 Access: (0600/-rw-------) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2014-09-21 10:52:26.000000000 -0400 Modify: 2014-09-21 10:52:26.000000000 -0400 Change: 2014-09-21 11:21:43.000000000 -0400 

编辑 :这是/usr/sbin/sshd -d的输出

  debug1: sshd version OpenSSH_5.3p1 debug1: read PEM private key done: type RSA debug1: private host key: #0 type 1 RSA debug1: read PEM private key done: type DSA debug1: private host key: #1 type 2 DSA debug1: rexec_argv[0]='/usr/sbin/sshd' debug1: rexec_argv[1]='-d' Set /proc/self/oom_score_adj from 0 to -1000 debug1: Bind to port 22 on 0.0.0.0. Bind to port 22 on 0.0.0.0 failed: Address already in use. debug1: Bind to port 22 on ::. Bind to port 22 on :: failed: Address already in use. Cannot bind any address. 

编辑 :这是grep 'sshd' /var/log/*的输出grep 'sshd' /var/log/* :二进制文件/ var / log / btmp匹配二进制文件/ var / log / btmp-20140901匹配/var/log/dovecot-info.log:Aug 08 09:10:03 pop3-login:Info:Disconnected(auth failed,1 attempts):user =,method = PLAIN,rip = 211.43.207.112,lip = 198.100.145.168 /var/log/install_rtm.log:rtm hINFO_TCP_LISTEN_IP- 0-0-0-0_PORT-22_procname | sshd /var/log/install_rtm.log:rtm hINFO_TCP_LISTEN_IP-0-0-0-0_PORT-22_cmdline | / usr / sbin / sshd /var/log/install_rtm.log:rtm hINFO_TCP_LISTEN_IP -0-0-0-0_PORT-22_exe | / usr / sbin / sshd /var/log/install_rtm.log:rtm hINFO_TCP_LISTEN_IP-0_PORT-22_procname | sshd /var/log/install_rtm.log:rtm hINFO_TCP_LISTEN_IP-0_PORT-22_cmdline | / usr / sbin / sshd /var/log/install_rtm.log:rtm hINFO_TCP_LISTEN_IP-0_PORT-22_exe | / usr / sbin / sshd

在/ etc / ssh / sshd_config中,将LogLevel设置为DEBUG3 ,然后service sshd restart

tail -F /var/log/secure > /root/tmp.txt :这是获取与testing相关的日志的有用方法; 虽然你会事先得到一些旧的线路。 它会挂起(如果你喜欢,你可以把它放在后台)

尝试再次validation(可能会失败)。 杀死你之前开始的tail -F ...工作。 在/root/tmp.txt很可能会出现失败的原因。

大多数情况下,它是由于/root/.ssh/authorized_keys格式不正确(或行包装)条目造成的(请注意美式英语拼写)。

其他常见原因:

  • AllowRoot设置为no;
  • PubKeyAuthentication设置为no(还要介意RSAAuthentication ,这是SSH版本1(应该被禁用)

你也可能在寻找一个可能会以不同方式对待你的Limit节。

检查selinux是否正在运行

 sestatus 

把它关掉(暂时)

 setenforce 0 

如果你被允许login,你有两个select:你可以通过编辑永久closures它:

 /etc/sysconfg/selinux 

我不记得这个文件是什么样子,但是IIRC非常简单。

或者,您可以确保在.ssh文件夹和文件上正确设置selinux上下文

restorecon -R〜/ .ssh

是selinux吗? 检查/ var / log / messages检查出来。 如果selinux不是问题。 尝试停止sshd服务,并在控制台上启动它:

 user@server# /usr/sbin/sshd -d 

这没有帮助,因为您已经使用主守护进程的端口。

  Bind to port 22 on :: failed: Address already in use. Cannot bind any address. 

SSHD pub pubauthentication可能会失败:

  1. 服务器用户的home〜/ .ssh的权限无效,使用700以外的权限(尝试检查是否与在src上的权限相同)
  2. 〜/ .ssh / authorized_keys用600以外的perms(试着检查一下你的perm是否和src一样)
  3. 〜/ .ssh或〜/ .ssh / authorized_keys的不同所有者(如果您使用scp与您的用户,我不认为这可能是一个问题)
  4. SElinux missconfiuration
  5. 错误的一组键

你可以退房

 #tail -f /var/log/secure 

当你正在尝试连接