Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过SSH密钥进行服务器身份验证失败_Ssh_Centos_Putty_Public Key - Fatal编程技术网

通过SSH密钥进行服务器身份验证失败

通过SSH密钥进行服务器身份验证失败,ssh,centos,putty,public-key,Ssh,Centos,Putty,Public Key,我试图在我的服务器(CentOS)上设置私钥/公钥身份验证。以下是我所做的步骤: 使用puttygen生成公共/私有密钥对 将公钥复制到服务器,并将其与cat命令一起附加到文件/root/.ssh/authorized\u keys 检查了.ssh(700)和.ssh/authorized_密钥(600)的建议文件所有权和权限 重新启动sshd服务 在Connection>SSH>Auth下的Putty配置中,选择privat密钥 但当我尝试与Putty连接时,我收到消息“服务器拒绝了我们的密钥

我试图在我的服务器(CentOS)上设置私钥/公钥身份验证。以下是我所做的步骤:

  • 使用puttygen生成公共/私有密钥对
  • 将公钥复制到服务器,并将其与cat命令一起附加到文件/root/.ssh/authorized\u keys
  • 检查了.ssh(700)和.ssh/authorized_密钥(600)的建议文件所有权和权限
  • 重新启动sshd服务
  • 在Connection>SSH>Auth下的Putty配置中,选择privat密钥
  • 但当我尝试与Putty连接时,我收到消息“服务器拒绝了我们的密钥”。然后系统会提示我输入密码,这样就可以了

    我还提高了身份验证日志级别,以下是失败尝试的输出:

        Aug 30 12:55:01 localhost sshd[44558]: debug3: fd 5 is not O_NONBLOCK
    Aug 30 12:55:01 localhost sshd[44558]: debug1: Forked child 44752.
    Aug 30 12:55:01 localhost sshd[44558]: debug3: send_rexec_state: entering fd = 8 config len 803
    Aug 30 12:55:01 localhost sshd[44558]: debug3: ssh_msg_send: type 0
    Aug 30 12:55:01 localhost sshd[44558]: debug3: send_rexec_state: done
    Aug 30 12:55:01 localhost sshd[44752]: debug3: oom_adjust_restore
    Aug 30 12:55:01 localhost sshd[44752]: Set /proc/self/oom_score_adj to 0
    Aug 30 12:55:01 localhost sshd[44752]: debug1: rexec start in 5 out 5 newsock 5 pipe 7 sock 8
    Aug 30 12:55:01 localhost sshd[44752]: debug1: inetd sockets after dupping: 3, 3
    Aug 30 12:55:01 localhost sshd[44752]: Connection from 91.15.164.238 port 58557 on 82.165.78.188 port 22
    Aug 30 12:55:01 localhost sshd[44752]: debug1: Client protocol version 2.0; client software version PuTTY_Release_0.70
    Aug 30 12:55:01 localhost sshd[44752]: debug1: no match: PuTTY_Release_0.70
    Aug 30 12:55:01 localhost sshd[44752]: debug1: Enabling compatibility mode for protocol 2.0
    Aug 30 12:55:01 localhost sshd[44752]: debug1: Local version string SSH-2.0-OpenSSH_6.6.1
    Aug 30 12:55:01 localhost sshd[44752]: debug2: fd 3 setting O_NONBLOCK
    Aug 30 12:55:01 localhost sshd[44752]: debug3: ssh_sandbox_init: preparing rlimit sandbox
    Aug 30 12:55:01 localhost sshd[44752]: debug2: Network child is on pid 44753
    Aug 30 12:55:01 localhost sshd[44752]: debug3: preauth child monitor started
    Aug 30 12:55:01 localhost sshd[44752]: debug1: SELinux support disabled [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug3: privsep user:group 74:74 [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug1: permanently_set_uid: 74/74 [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug1: list_hostkey_types: ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519 [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug1: SSH2_MSG_KEXINIT sent [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug1: SSH2_MSG_KEXINIT received [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit: ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519 [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96 [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96 [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit: none,zlib@openssh.com [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit: none,zlib@openssh.com [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit:  [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit:  [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit: first_kex_follows 0  [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit: reserved 0  [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,rsa2048-sha256,rsa1024-sha1,diffie-hellman-group1-sha1 [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit: ssh-rsa,ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-dss [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit: aes256-ctr,aes256-cbc,rijndael-cbc@lysator.liu.se,aes192-ctr,aes192-cbc,aes128-ctr,aes128-cbc,chacha20-poly1305@openssh.com,blowfish-ctr,blowfish-cbc,3des-ctr,3des-cbc,arcfour256,arcfour128 [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit: aes256-ctr,aes256-cbc,rijndael-cbc@lysator.liu.se,aes192-ctr,aes192-cbc,aes128-ctr,aes128-cbc,chacha20-poly1305@openssh.com,blowfish-ctr,blowfish-cbc,3des-ctr,3des-cbc,arcfour256,arcfour128 [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit: hmac-sha2-256,hmac-sha1,hmac-sha1-96,hmac-md5,hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-etm@openssh.com [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit: hmac-sha2-256,hmac-sha1,hmac-sha1-96,hmac-md5,hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-etm@openssh.com [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit: none,zlib [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit: none,zlib [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit:  [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit:  [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit: first_kex_follows 0  [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_parse_kexinit: reserved 0  [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: mac_setup: setup hmac-sha2-256 [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug1: kex: client->server aes256-ctr hmac-sha2-256 none [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: mac_setup: setup hmac-sha2-256 [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug1: kex: server->client aes256-ctr hmac-sha2-256 none [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug1: kex: curve25519-sha256@libssh.org need=32 dh_need=32 [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug3: mm_request_send entering: type 120 [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug3: mm_request_receive_expect entering: type 121 [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug3: mm_request_receive entering [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug3: mm_request_receive entering
    Aug 30 12:55:01 localhost sshd[44752]: debug3: monitor_read: checking request 120
    Aug 30 12:55:01 localhost sshd[44752]: debug3: mm_request_send entering: type 121
    Aug 30 12:55:01 localhost sshd[44752]: debug1: kex: curve25519-sha256@libssh.org need=32 dh_need=32 [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug3: mm_request_send entering: type 120 [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug3: mm_request_receive_expect entering: type 121 [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug3: mm_request_receive entering [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug3: mm_request_receive entering
    Aug 30 12:55:01 localhost sshd[44752]: debug3: monitor_read: checking request 120
    Aug 30 12:55:01 localhost sshd[44752]: debug3: mm_request_send entering: type 121
    Aug 30 12:55:01 localhost sshd[44752]: debug1: expecting SSH2_MSG_KEX_ECDH_INIT [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug3: mm_key_sign entering [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug3: mm_request_send entering: type 6 [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug3: mm_key_sign: waiting for MONITOR_ANS_SIGN [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug3: mm_request_receive_expect entering: type 7 [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug3: mm_request_receive entering [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug3: mm_request_receive entering
    Aug 30 12:55:01 localhost sshd[44752]: debug3: monitor_read: checking request 6
    Aug 30 12:55:01 localhost sshd[44752]: debug3: mm_answer_sign
    Aug 30 12:55:01 localhost sshd[44752]: debug3: mm_answer_sign: signature 0x7f0b70e15390(271)
    Aug 30 12:55:01 localhost sshd[44752]: debug3: mm_request_send entering: type 7
    Aug 30 12:55:01 localhost sshd[44752]: debug2: monitor_read: 6 used once, disabling now
    Aug 30 12:55:01 localhost sshd[44752]: debug2: kex_derive_keys [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: set_newkeys: mode 1 [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug1: SSH2_MSG_NEWKEYS sent [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug1: expecting SSH2_MSG_NEWKEYS [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug2: set_newkeys: mode 0 [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug1: SSH2_MSG_NEWKEYS received [preauth]
    Aug 30 12:55:01 localhost sshd[44752]: debug1: KEX done [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug1: userauth-request for user root service ssh-connection method none [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug1: attempt 0 failures 0 [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_getpwnamallow entering [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_request_send entering: type 8 [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_getpwnamallow: waiting for MONITOR_ANS_PWNAM [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_request_receive_expect entering: type 9 [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_request_receive entering [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_request_receive entering
    Aug 30 12:55:04 localhost sshd[44752]: debug3: monitor_read: checking request 8
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_answer_pwnamallow
    Aug 30 12:55:04 localhost sshd[44752]: debug3: Trying to reverse map address 91.15.164.238.
    Aug 30 12:55:04 localhost sshd[44752]: debug2: parse_server_config: config reprocess config len 803
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_answer_pwnamallow: sending MONITOR_ANS_PWNAM: 1
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_request_send entering: type 9
    Aug 30 12:55:04 localhost sshd[44752]: debug2: monitor_read: 8 used once, disabling now
    Aug 30 12:55:04 localhost sshd[44752]: debug2: input_userauth_request: setting up authctxt for root [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_start_pam entering [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_request_send entering: type 100 [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_inform_authserv entering [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_request_send entering: type 4 [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_inform_authrole entering [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_request_send entering: type 80 [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug2: input_userauth_request: try method none [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: userauth_finish: failure partial=0 next methods="publickey,gssapi-keyex,gssapi-with-mic,password" [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_request_receive entering
    Aug 30 12:55:04 localhost sshd[44752]: debug3: monitor_read: checking request 100
    Aug 30 12:55:04 localhost sshd[44752]: debug1: PAM: initializing for "root"
    Aug 30 12:55:04 localhost sshd[44752]: debug1: PAM: setting PAM_RHOST to "p5b0fa4ee.dip0.t-ipconnect.de"
    Aug 30 12:55:04 localhost sshd[44752]: debug1: PAM: setting PAM_TTY to "ssh"
    Aug 30 12:55:04 localhost sshd[44752]: debug2: monitor_read: 100 used once, disabling now
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_request_receive entering
    Aug 30 12:55:04 localhost sshd[44752]: debug3: monitor_read: checking request 4
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_answer_authserv: service=ssh-connection, style=
    Aug 30 12:55:04 localhost sshd[44752]: debug2: monitor_read: 4 used once, disabling now
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_request_receive entering
    Aug 30 12:55:04 localhost sshd[44752]: debug3: monitor_read: checking request 80
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_answer_authrole: role=
    Aug 30 12:55:04 localhost sshd[44752]: debug2: monitor_read: 80 used once, disabling now
    Aug 30 12:55:04 localhost sshd[44752]: debug1: userauth-request for user root service ssh-connection method publickey [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug1: attempt 1 failures 0 [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug2: input_userauth_request: try method publickey [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug1: test whether pkalg/pkblob are acceptable [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_key_allowed entering [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_request_send entering: type 22 [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_key_allowed: waiting for MONITOR_ANS_KEYALLOWED [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_request_receive_expect entering: type 23 [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_request_receive entering [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_request_receive entering
    Aug 30 12:55:04 localhost sshd[44752]: debug3: monitor_read: checking request 22
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_answer_keyallowed entering
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_answer_keyallowed: key_from_blob: 0x7f0b70e1ca10
    Aug 30 12:55:04 localhost sshd[44752]: debug1: temporarily_use_uid: 0/0 (e=0/0)
    Aug 30 12:55:04 localhost sshd[44752]: debug1: trying public key file /root/.ssh/authorized_keys
    Aug 30 12:55:04 localhost sshd[44752]: debug1: fd 4 clearing O_NONBLOCK
    Aug 30 12:55:04 localhost sshd[44752]: debug2: key_type_from_name: unknown key type '----'
    Aug 30 12:55:04 localhost sshd[44752]: debug3: key_read: missing keytype
    Aug 30 12:55:04 localhost sshd[44752]: debug2: user_key_allowed: check options: '---- BEGIN SSH2 PUBLIC KEY ----\r\n'
    Aug 30 12:55:04 localhost sshd[44752]: debug2: key_type_from_name: unknown key type 'BEGIN'
    Aug 30 12:55:04 localhost sshd[44752]: debug3: key_read: missing keytype
    Aug 30 12:55:04 localhost sshd[44752]: debug2: user_key_allowed: advance: 'BEGIN SSH2 PUBLIC KEY ----\r\n'
    Aug 30 12:55:04 localhost sshd[44752]: debug2: key_type_from_name: unknown key type 'Comment:'
    Aug 30 12:55:04 localhost sshd[44752]: debug3: key_read: missing keytype
    Aug 30 12:55:04 localhost sshd[44752]: debug2: user_key_allowed: check options: 'Comment: "rsa-key-20170830"\r\n'
    Aug 30 12:55:04 localhost sshd[44752]: debug3: key_read: missing whitespace
    Aug 30 12:55:04 localhost sshd[44752]: debug2: user_key_allowed: advance: '"rsa-key-20170830"\r\n'
    Aug 30 12:55:04 localhost sshd[44752]: debug3: key_read: missing whitespace
    Aug 30 12:55:04 localhost sshd[44752]: debug2: user_key_allowed: check options: 'AAAAB3NzaC1yc2EAAAABJQAAAQEAkO9lXNIVuohGAOsCQy+NDIJv7a+a6z6ekmSp\r\n'
    Aug 30 12:55:04 localhost sshd[44752]: debug3: key_read: missing whitespace
    Aug 30 12:55:04 localhost sshd[44752]: debug2: user_key_allowed: advance: ''
    Aug 30 12:55:04 localhost sshd[44752]: debug3: key_read: missing whitespace
    Aug 30 12:55:04 localhost sshd[44752]: debug2: user_key_allowed: check options: 'HfFduHAvOadeX/HDidL1696CVOHjX8fJ7ITTCaFl2ljI06lobZ2baDAsezpMhut9\r\n'
    Aug 30 12:55:04 localhost sshd[44752]: debug3: key_read: missing whitespace
    Aug 30 12:55:04 localhost sshd[44752]: debug2: user_key_allowed: advance: ''
    Aug 30 12:55:04 localhost sshd[44752]: debug3: key_read: missing whitespace
    Aug 30 12:55:04 localhost sshd[44752]: debug2: user_key_allowed: check options: 'xmovTOmTJK3pOAI9E1S3Hmhum0QViFsE5oCiMHwZixLmWoeZt09ZwSZyQZAvtHTU\r\n'
    Aug 30 12:55:04 localhost sshd[44752]: debug3: key_read: missing whitespace
    Aug 30 12:55:04 localhost sshd[44752]: debug2: user_key_allowed: advance: ''
    Aug 30 12:55:04 localhost sshd[44752]: debug3: key_read: missing whitespace
    Aug 30 12:55:04 localhost sshd[44752]: debug2: user_key_allowed: check options: '73bviqiky/j2xYpG+5QKyViyCEAa6KbJKnGpLw8UTf0rEBhUES9wLBt4vU3AZuQd\r\n'
    Aug 30 12:55:04 localhost sshd[44752]: debug3: key_read: missing whitespace
    Aug 30 12:55:04 localhost sshd[44752]: debug2: user_key_allowed: advance: ''
    Aug 30 12:55:04 localhost sshd[44752]: debug3: key_read: missing whitespace
    Aug 30 12:55:04 localhost sshd[44752]: debug2: user_key_allowed: check options: 'evfZSr3lDBlCCdX3vyJJP8m4x3+8YMSvJSfKa9MErWpxjNE+4GMhyexNILSP+lgy\r\n'
    Aug 30 12:55:04 localhost sshd[44752]: debug3: key_read: missing whitespace
    Aug 30 12:55:04 localhost sshd[44752]: debug2: user_key_allowed: advance: ''
    Aug 30 12:55:04 localhost sshd[44752]: debug3: key_read: missing whitespace
    Aug 30 12:55:04 localhost sshd[44752]: debug2: user_key_allowed: check options: '5tqWIehpSekThkJLpi0KPvGiK/bm7oXMVNLN0KdLAf/MKUzB9w==\r\n'
    Aug 30 12:55:04 localhost sshd[44752]: debug3: key_read: missing whitespace
    Aug 30 12:55:04 localhost sshd[44752]: debug2: user_key_allowed: advance: ''
    Aug 30 12:55:04 localhost sshd[44752]: debug2: key_type_from_name: unknown key type '----'
    Aug 30 12:55:04 localhost sshd[44752]: debug3: key_read: missing keytype
    Aug 30 12:55:04 localhost sshd[44752]: debug2: user_key_allowed: check options: '---- END SSH2 PUBLIC KEY ----\r\n'
    Aug 30 12:55:04 localhost sshd[44752]: debug2: key_type_from_name: unknown key type 'END'
    Aug 30 12:55:04 localhost sshd[44752]: debug3: key_read: missing keytype
    Aug 30 12:55:04 localhost sshd[44752]: debug2: user_key_allowed: advance: 'END SSH2 PUBLIC KEY ----\r\n'
    Aug 30 12:55:04 localhost sshd[44752]: debug2: key not found
    Aug 30 12:55:04 localhost sshd[44752]: debug1: restore_uid: 0/0
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_answer_keyallowed: key 0x7f0b70e1ca10 is not allowed
    Aug 30 12:55:04 localhost sshd[44752]: Failed publickey for root from 91.15.164.238 port 58557 ssh2: RSA 4c:13:08:b4:06:eb:ea:98:54:69:50:3e:cf:22:9e:da
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_request_send entering: type 23
    Aug 30 12:55:04 localhost sshd[44752]: debug2: userauth_pubkey: authenticated 0 pkalg ssh-rsa [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: userauth_finish: failure partial=0 next methods="publickey,gssapi-keyex,gssapi-with-mic,password" [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug1: userauth-request for user root service ssh-connection method gssapi-with-mic [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug1: attempt 2 failures 1 [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug2: input_userauth_request: try method gssapi-with-mic [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_request_send entering: type 42 [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_request_receive_expect entering: type 43 [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_request_receive entering [preauth]
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_request_receive entering
    Aug 30 12:55:04 localhost sshd[44752]: debug3: monitor_read: checking request 42
    Aug 30 12:55:04 localhost sshd[44752]: debug1: Unspecified GSS failure.  Minor code may provide more information\nKey table file '/etc/krb5.keytab' not found\n
    Aug 30 12:55:04 localhost sshd[44752]: debug3: mm_request_send entering: type 43
    Aug 30 12:55:04 localhost sshd[44752]: debug3: userauth_finish: failure partial=0 next methods="publickey,gssapi-keyex,gssapi-with-mic,password" [preauth]
    

    以下是它不起作用的原因。正如许多分步教程所建议的,应该生成公钥文件,将其复制到服务器,然后使用cat命令将公钥附加到授权密钥文件中,如下所示:

    cat id\u rsa.mypublickey.pub>~/.ssh/authorized\u keys

    在我的案例中,我使用PuTTYgen生成密钥。但生成的公钥文件(使用“保存”按钮时保存的文件)在语法上不适用于附加到授权的密钥

    要获得正确格式化的公钥字符串,请将生成的代码段从PuTTYgen窗口复制并粘贴到~/.ssh/authorized_keys文件中的一行。格式正确的行如下所示,但语法也允许注释和其他内容:

    ssh-rsa AAAAB3NzaEAAAAB/*...more letters...*/cPogeHB2XQBQ== rsa-key-20170831
    
    要以Putty以外的其他ssh代理可以使用的格式获取私钥,可以使用PuTTYgen的转换选项并以OpenSSH格式保存密钥


    正如用户ilansch所建议的,在这里可以找到更全面的信息:

    您的ssh公钥没有复制到远程系统。或者它被部分复制了

    Aug 30 12:55:04 localhost sshd[44752]: Failed publickey for root from 91.15.164.238 port 58557 ssh2: RSA 4c:13:08:b4:06:eb:ea:98:54:69:50:3e:cf:22:9e:da
    
    这一点很重要

    为了避免复制SSH密钥时出现任何错误,我建议使用以下命令

    # ssh-copy-id root@myserver.example.com
    OR
    # ssh-copy-id -i ~/.ssh/mykey root@myserver.example.com
    
    并确保您在远程系统中拥有正确的所有权

    chown myuser:myuser -R ~/.ssh/authorized_keys
    
    如果再次失败,请在执行ssh时尝试指定特定密钥

    ssh -i ~/.ssh/mykey_id_rsa root@myserver.example.com
    

    如果反对者能给我一个提示,为什么他们反对这个问题,那就太好了,谢谢!我没有投反对票。。但是@ilansch好的,这是一个更好更全面的答案,但问题是不同的。Stackoverflow是一个编程问题的网站,因此这是离题的。@James K Polk,我理解,谢谢你提供的信息!