ssh 拒绝验证密钥

ssh 拒绝验证密钥

因此,我正在我的计算机 [fedora 17] 和在 Virtual Box 中运行的虚拟机之间建立连接,其中运行的是 CentOS 5。我已经从 CentOS 上的存储库安装了 openssh,并且已按如下方式配置了所有内容:

Protocol 2

HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key

SyslogFacility AUTHPRIV

PermitRootLogin yes

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile  /home/pigreco/.ssh/authorized_keys

PasswordAuthentication no

ChallengeResponseAuthentication yes

GSSAPIAuthentication yes
GSSAPICleanupCredentials yes

UsePAM yes

AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS

X11Forwarding yes

Subsystem   sftp    /usr/libexec/openssh/sftp-server

这是服务器上(即 CentOS 上的)的配置文件 sshd_config。此外,我像往常一样在我的操作系统(即 Fedora)的主目录中的 .ssh/ 文件夹中创建了公钥/私钥对,然后使用 scp 将 id_rsa.pub 复制到服务器,然后将其内容附加到服务器计算机上的 .ssh/authorized_keys 文件中。

我收到的错误如下:

OpenSSH_5.9p1, OpenSSL 1.0.0j-fips 10 May 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 50: Applying options for *
debug1: Connecting to 192.168.100.13 [192.168.100.13] port 22.
debug1: Connection established.
debug1: identity file /home/mayhem/.ssh/identity type -1
debug1: identity file /home/mayhem/.ssh/identity-cert type -1
debug1: identity file /home/mayhem/.ssh/id_rsa type 1
debug1: identity file /home/mayhem/.ssh/id_rsa-cert type -1
debug1: identity file /home/mayhem/.ssh/id_dsa type -1
debug1: identity file /home/mayhem/.ssh/id_dsa-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.9
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 16:e5:72:d1:37:94:1b:5e:3d:3a:e5:da:6f:df:0c:08
debug1: Host '192.168.100.13' is known and matches the RSA host key.
debug1: Found key in /home/mayhem/.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,keyboard-interactive
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
Cannot determine realm for numeric host address

debug1: Unspecified GSS failure.  Minor code may provide more information
Cannot determine realm for numeric host address

debug1: Unspecified GSS failure.  Minor code may provide more information


debug1: Unspecified GSS failure.  Minor code may provide more information
Cannot determine realm for numeric host address

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/mayhem/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
Agent admitted failure to sign using the key.
debug1: Trying private key: /home/mayhem/.ssh/identity
debug1: Trying private key: /home/mayhem/.ssh/id_dsa
debug1: Next authentication method: keyboard-interactive

你对我应该做什么有什么好的建议吗?谢谢

答案1

ssh-agent尝试使用您的私钥签署通信,但失败了。如果您还没有这样做,请尝试运行ssh-add以将私钥添加到代理(运行时不带参数,命令会自动尝试加载默认密钥文件)。如果您已经加载密钥,请尝试export SSH_AUTH_SOCK=0

答案2

您对 authorized_keys 文件的位置进行硬编码有什么特殊原因吗?OpenSSH 对文件及其父目录的权限非常严格。服务器也不会告诉客户端密钥被拒绝的原因。查看您的日志文件,看看 sshd 拒绝密钥的原因。检查以下文件之一: /var/log/secure/var/log/auth.log在服务器上。您需要 root 访问权限。

答案3

这对我有用:

restorecon -R $用户/.ssh

https://www.centos.org/forums/viewtopic.php?t=8990

相关内容