• SSH 免密登录:普通用户免密配置登录仍需输入密码


    一、服务器信息

    服务器系统IP
    Acentos7192.168.0.100
    Bcentos7192.168.0.101
    Ccentos7192.168.0.102

    二、免密配置

    1.1 A 服务器操作

    (1)生成密钥文件

    1. [test@localhost ~]$ ssh-keygen -t rsa
    2. [test@localhost ~]$ ll .ssh/
    3. total 8
    4. -rw-------. 1 test test 1679 Sep 1 07:40 id_rsa
    5. -rw-r--r--. 1 test test 408 Sep 1 07:40 id_rsa.pub

     (2)复制密钥文件到 B 服务器

    1. [test@localhost ~]$ ssh-copy-id test@192.168.0.101
    2. /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/test/.ssh/id_rsa.pub"
    3. /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
    4. /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
    5. Authorized users only. All activities may be monitored and reported.
    6. test@192.168.0.101's password:
    7. Number of key(s) added: 1
    8. Now try logging into the machine, with: "ssh 'test@192.168.0.101'"
    9. and check to make sure that only the key(s) you wanted were added.

    (3)查看 B 服务器写入信息

    1. [test@localhost ~]$ ll -a
    2. 总用量 24
    3. drwxrwxrwx 8 test test 182 831 17:34 .
    4. drwxr-xr-x 6 root root 103 627 11:57 ..
    5. -rw------- 1 test test 70 831 17:34 .bash_history
    6. -rwxr-xr-x 1 test test 75 110 2020 .bash_logout
    7. -rwxr-xr-x 1 test test 71 319 2020 .bash_profile
    8. -rwxr-xr-x 1 test test 138 110 2020 .bashrc
    9. drwxr-x--- 3 test test 17 627 15:22 .cache
    10. drwx------ 3 test test 20 627 14:39 .config
    11. drwx------ 2 test test 29 91 16:19 .ssh
    12. [test@localhost ~]$ ll .ssh/
    13. 总用量 4
    14. -rw------- 1 test test 592 91 16:19 authorized_keys
    15. [test@localhost ~]$ cat .ssh/authorized_keys
    16. ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCuj0mF2RWCQ8oLCN7qNAJUMRw8e4k8Hrv2xcjSB182EYBJ60EOjOk2W6RCwpupjZRl2wMY8cYyPY2Q7m4YHRJY99kpve9Xq2rdvbDH/MifblEAZIfo4rmi4Od34qhHB30i1X5iMl/58wVoe/VooQqa0iZIK+j6AgmiSJSOsdT3yhHeHYnMc0pecZzhCF3v+hDQPxI0JxVwLJZLlBIeFRa7+mpxOmEollZUzVYwdy9CfYpAgdyPyeWo2pU0me0GhvTT6vuqU9ttdwCK5jIRhOH71croaAwY6p0tQcVeK89Z4YMxZith3lEiMY3HuEX2B6bL0naZH50o8VERB0pCx6JkNR1TwNNKc59gFzFLMMw/xXCJICGEU9LGQPQMvV8k4SNm7UNmESXjUoPcea0z/NusPjYuOoE42LcJWxcVSfg7kB0YTQoLX4IWuHAbAZkRjhmw50VIgvfb1PxXwlRpLW9sjOq/68zIr+/n6clMpZR5d+qV1CmnnQ8EgOwmNYgz7z8= test@localhost.localdomain

    (4)A 服务器尝试登录 B 服务器(这里还是提示需要输入密码,正常情况下是不需要的)

    1. [test@localhost ~]$ ssh test@192.168.0.101
    2. Authorized users only. All activities may be monitored and reported.
    3. test@192.168.0.101's password:

    (5)正常与异常情况对比

    正常情况:

    1. [test@localhost .ssh]$ ssh -vvv 'test@192.168.0.102'
    2. OpenSSH_8.2p1, OpenSSL 1.1.1f 31 Mar 2020
    3. debug1: Reading configuration data /etc/ssh/ssh_config
    4. debug3: /etc/ssh/ssh_config line 51: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0
    5. debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
    6. debug2: checking match for 'final all' host 192.168.0.102 originally 192.168.0.102
    7. debug3: /etc/ssh/ssh_config.d/05-redhat.conf line 3: not matched 'final'
    8. debug2: match not found
    9. debug3: /etc/ssh/ssh_config.d/05-redhat.conf line 5: Including file /etc/crypto-policies/back-ends/openssh.config depth 1 (parse only)
    10. debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
    11. debug3: gss kex names ok: [gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1-,gss-group1-sha1-]
    12. debug3: kex names ok: [curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1]
    13. debug1: configuration requests final Match pass
    14. debug2: resolve_canonicalize: hostname 192.168.0.102 is address
    15. debug1: re-parsing configuration
    16. debug1: Reading configuration data /etc/ssh/ssh_config
    17. debug3: /etc/ssh/ssh_config line 51: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0
    18. debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
    19. debug2: checking match for 'final all' host 192.168.0.102 originally 192.168.0.102
    20. debug3: /etc/ssh/ssh_config.d/05-redhat.conf line 3: matched 'final'
    21. debug2: match found
    22. debug3: /etc/ssh/ssh_config.d/05-redhat.conf line 5: Including file /etc/crypto-policies/back-ends/openssh.config depth 1
    23. debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
    24. debug3: gss kex names ok: [gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1-,gss-group1-sha1-]
    25. debug3: kex names ok: [curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1]
    26. debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
    27. debug2: ssh_connect_direct
    28. debug1: Connecting to 192.168.0.102 [192.168.0.102] port 22.
    29. debug1: Connection established.
    30. debug1: identity file /home/test/.ssh/id_rsa type 0
    31. debug1: identity file /home/test/.ssh/id_rsa-cert type -1
    32. debug1: identity file /home/test/.ssh/id_dsa type -1
    33. debug1: identity file /home/test/.ssh/id_dsa-cert type -1
    34. debug1: identity file /home/test/.ssh/id_ecdsa type -1
    35. debug1: identity file /home/test/.ssh/id_ecdsa-cert type -1
    36. debug1: identity file /home/test/.ssh/id_ecdsa_sk type -1
    37. debug1: identity file /home/test/.ssh/id_ecdsa_sk-cert type -1
    38. debug1: identity file /home/test/.ssh/id_ed25519 type -1
    39. debug1: identity file /home/test/.ssh/id_ed25519-cert type -1
    40. debug1: identity file /home/test/.ssh/id_ed25519_sk type -1
    41. debug1: identity file /home/test/.ssh/id_ed25519_sk-cert type -1
    42. debug1: identity file /home/test/.ssh/id_xmss type -1
    43. debug1: identity file /home/test/.ssh/id_xmss-cert type -1
    44. debug1: Local version string SSH-2.0-OpenSSH_8.2
    45. debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2
    46. debug1: match: OpenSSH_8.2 pat OpenSSH* compat 0x04000000
    47. debug2: fd 5 setting O_NONBLOCK
    48. debug1: Authenticating to 192.168.0.102:22 as 'test'
    49. debug3: hostkeys_foreach: reading file "/home/test/.ssh/known_hosts"
    50. debug3: record_hostkey: found key type ECDSA in file /home/test/.ssh/known_hosts:6
    51. debug3: load_hostkeys: loaded 1 keys from 192.168.0.102
    52. debug3: order_hostkeyalgs: have matching best-preference key type ecdsa-sha2-nistp256-cert-v01@openssh.com, using HostkeyAlgorithms verbatim
    53. debug3: send packet: type 20
    54. debug1: SSH2_MSG_KEXINIT sent
    55. debug3: receive packet: type 20
    56. debug1: SSH2_MSG_KEXINIT received
    57. debug2: local client KEXINIT proposal
    58. debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1,ext-info-c
    59. debug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com,ssh-ed25519,sk-ssh-ed25519@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa
    60. debug2: ciphers ctos: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc
    61. debug2: ciphers stoc: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc
    62. debug2: MACs ctos: hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha1,umac-128@openssh.com,hmac-sha2-512
    63. debug2: MACs stoc: hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha1,umac-128@openssh.com,hmac-sha2-512
    64. debug2: compression ctos: none,zlib@openssh.com,zlib
    65. debug2: compression stoc: none,zlib@openssh.com,zlib
    66. debug2: languages ctos:
    67. debug2: languages stoc:
    68. debug2: first_kex_follows 0
    69. debug2: reserved 0
    70. debug2: peer server KEXINIT proposal
    71. debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256
    72. debug2: host key algorithms: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519
    73. debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com
    74. debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com
    75. debug2: MACs ctos: hmac-sha2-512,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha2-256-etm@openssh.com
    76. debug2: MACs stoc: hmac-sha2-512,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha2-256-etm@openssh.com
    77. debug2: compression ctos: none,zlib@openssh.com
    78. debug2: compression stoc: none,zlib@openssh.com
    79. debug2: languages ctos:
    80. debug2: languages stoc:
    81. debug2: first_kex_follows 0
    82. debug2: reserved 0
    83. debug1: kex: algorithm: curve25519-sha256
    84. debug1: kex: host key algorithm: ecdsa-sha2-nistp256
    85. debug1: kex: server->client cipher: aes256-gcm@openssh.com MAC: <implicit> compression: none
    86. debug1: kex: client->server cipher: aes256-gcm@openssh.com MAC: <implicit> compression: none
    87. debug1: kex: curve25519-sha256 need=32 dh_need=32
    88. debug1: kex: curve25519-sha256 need=32 dh_need=32
    89. debug3: send packet: type 30
    90. debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
    91. debug3: receive packet: type 31
    92. debug1: Server host key: ecdsa-sha2-nistp256 SHA256:xZRYT7h3RsY4d0oJEcOJ6fVcR1dPkXL4y6N+CQ2v9R8
    93. debug3: hostkeys_foreach: reading file "/home/test/.ssh/known_hosts"
    94. debug3: record_hostkey: found key type ECDSA in file /home/test/.ssh/known_hosts:6
    95. debug3: load_hostkeys: loaded 1 keys from 192.168.0.102
    96. debug1: Host '192.168.0.102' is known and matches the ECDSA host key.
    97. debug1: Found key in /home/test/.ssh/known_hosts:6
    98. debug3: send packet: type 21
    99. debug2: set_newkeys: mode 1
    100. debug1: rekey out after 4294967296 blocks
    101. debug1: SSH2_MSG_NEWKEYS sent
    102. debug1: expecting SSH2_MSG_NEWKEYS
    103. debug3: receive packet: type 21
    104. debug1: SSH2_MSG_NEWKEYS received
    105. debug2: set_newkeys: mode 0
    106. debug1: rekey in after 4294967296 blocks
    107. debug1: Will attempt key: /home/test/.ssh/id_rsa RSA SHA256:tCwCdkILafCNjTDeB5Ci/XNv1d2XF5UGtlHXYM8Frtg
    108. debug1: Will attempt key: /home/test/.ssh/id_dsa
    109. debug1: Will attempt key: /home/test/.ssh/id_ecdsa
    110. debug1: Will attempt key: /home/test/.ssh/id_ecdsa_sk
    111. debug1: Will attempt key: /home/test/.ssh/id_ed25519
    112. debug1: Will attempt key: /home/test/.ssh/id_ed25519_sk
    113. debug1: Will attempt key: /home/test/.ssh/id_xmss
    114. debug2: pubkey_prepare: done
    115. debug3: send packet: type 5
    116. debug3: receive packet: type 7
    117. debug1: SSH2_MSG_EXT_INFO received
    118. debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com>
    119. debug3: receive packet: type 6
    120. debug2: service_accept: ssh-userauth
    121. debug1: SSH2_MSG_SERVICE_ACCEPT received
    122. debug3: send packet: type 50
    123. debug3: receive packet: type 53
    124. debug3: input_userauth_banner
    125. Authorized users only. All activities may be monitored and reported.
    126. debug3: receive packet: type 51
    127. debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
    128. debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password
    129. debug3: preferred gssapi-with-mic,publickey,keyboard-interactive,password
    130. debug3: authmethod_lookup gssapi-with-mic
    131. debug3: remaining preferred: publickey,keyboard-interactive,password
    132. debug3: authmethod_is_enabled gssapi-with-mic
    133. debug1: Next authentication method: gssapi-with-mic
    134. debug1: Unspecified GSS failure. Minor code may provide more information
    135. No Kerberos credentials available: No KCM server found
    136. debug1: Unspecified GSS failure. Minor code may provide more information
    137. No Kerberos credentials available: No KCM server found
    138. debug2: we did not send a packet, disable method
    139. debug3: authmethod_lookup publickey
    140. debug3: remaining preferred: keyboard-interactive,password
    141. debug3: authmethod_is_enabled publickey
    142. debug1: Next authentication method: publickey
    143. debug1: Offering public key: /home/test/.ssh/id_rsa RSA SHA256:tCwCdkILafCNjTDeB5Ci/XNv1d2XF5UGtlHXYM8Frtg
    144. debug3: send packet: type 50
    145. debug2: we sent a publickey packet, wait for reply
    146. debug3: receive packet: type 60
    147. debug1: Server accepts key: /home/test/.ssh/id_rsa RSA SHA256:tCwCdkILafCNjTDeB5Ci/XNv1d2XF5UGtlHXYM8Frtg
    148. debug3: sign_and_send_pubkey: RSA SHA256:tCwCdkILafCNjTDeB5Ci/XNv1d2XF5UGtlHXYM8Frtg
    149. debug3: sign_and_send_pubkey: signing using rsa-sha2-256 SHA256:tCwCdkILafCNjTDeB5Ci/XNv1d2XF5UGtlHXYM8Frtg
    150. debug3: send packet: type 50
    151. debug3: receive packet: type 52
    152. debug1: Authentication succeeded (publickey).
    153. Authenticated to 192.168.0.102 ([192.168.0.102]:22).
    154. debug1: channel 0: new [client-session]
    155. debug3: ssh_session2_open: channel_new: 0
    156. debug2: channel 0: send open
    157. debug3: send packet: type 90
    158. debug1: Requesting no-more-sessions@openssh.com
    159. debug3: send packet: type 80
    160. debug1: Entering interactive session.
    161. debug1: pledge: network
    162. debug3: receive packet: type 80
    163. debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
    164. debug3: receive packet: type 4
    165. debug1: Remote: /home/test/.ssh/authorized_keys:2: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
    166. debug3: receive packet: type 4
    167. debug1: Remote: /home/test/.ssh/authorized_keys:2: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
    168. debug3: receive packet: type 91
    169. debug2: channel_input_open_confirmation: channel 0: callback start
    170. debug2: fd 5 setting TCP_NODELAY
    171. debug3: ssh_packet_set_tos: set IP_TOS 0x48
    172. debug2: client_session2_setup: id 0
    173. debug2: channel 0: request pty-req confirm 1
    174. debug3: send packet: type 98
    175. debug1: Sending environment.
    176. debug3: Ignored env SHELL
    177. debug3: Ignored env HISTCONTROL
    178. debug3: Ignored env HISTSIZE
    179. debug3: Ignored env HOSTNAME
    180. debug3: Ignored env JAVA_HOME
    181. debug3: Ignored env JRE_HOME
    182. debug3: Ignored env PWD
    183. debug3: Ignored env LOGNAME
    184. debug3: Ignored env HOME
    185. debug1: Sending env LANG = zh_CN.UTF-8
    186. debug2: channel 0: request env confirm 0
    187. debug3: send packet: type 98
    188. debug3: Ignored env LS_COLORS
    189. debug3: Ignored env TERM
    190. debug3: Ignored env USER
    191. debug3: Ignored env ZOOKEEPER_HOME
    192. debug3: Ignored env SHLVL
    193. debug3: Ignored env ZIPINFO
    194. debug3: Ignored env UNZIP
    195. debug3: Ignored env TMOUT
    196. debug3: Ignored env XDG_DATA_DIRS
    197. debug3: Ignored env PATH
    198. debug3: Ignored env CLASS_PATH
    199. debug3: Ignored env MAIL
    200. debug3: Ignored env _
    201. debug3: Ignored env OLDPWD
    202. debug2: channel 0: request shell confirm 1
    203. debug3: send packet: type 98
    204. debug2: channel_input_open_confirmation: channel 0: callback done
    205. debug2: channel 0: open confirm rwindow 0 rmax 32768
    206. debug3: receive packet: type 99
    207. debug2: channel_input_status_confirm: type 99 id 0
    208. debug2: PTY allocation request accepted on channel 0
    209. debug2: channel 0: rcvd adjust 2097152
    210. debug3: receive packet: type 99
    211. debug2: channel_input_status_confirm: type 99 id 0
    212. debug2: shell request accepted on channel 0
    213. Authorized users only. All activities may be monitored and reported.
    214. Web console: https://localhost:9090/
    215. Last login: Fri Sep 1 11:11:55 2023
    216. [test@localhost ~]$

    异常情况:

    1. [test@localhost .ssh]$ ssh -vvv 'test@192.168.0.101'
    2. OpenSSH_8.2p1, OpenSSL 1.1.1f 31 Mar 2020
    3. debug1: Reading configuration data /etc/ssh/ssh_config
    4. debug3: /etc/ssh/ssh_config line 51: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0
    5. debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
    6. debug2: checking match for 'final all' host 192.168.0.101 originally 192.168.0.101
    7. debug3: /etc/ssh/ssh_config.d/05-redhat.conf line 3: not matched 'final'
    8. debug2: match not found
    9. debug3: /etc/ssh/ssh_config.d/05-redhat.conf line 5: Including file /etc/crypto-policies/back-ends/openssh.config depth 1 (parse only)
    10. debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
    11. debug3: gss kex names ok: [gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1-,gss-group1-sha1-]
    12. debug3: kex names ok: [curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1]
    13. debug1: configuration requests final Match pass
    14. debug2: resolve_canonicalize: hostname 192.168.0.101 is address
    15. debug1: re-parsing configuration
    16. debug1: Reading configuration data /etc/ssh/ssh_config
    17. debug3: /etc/ssh/ssh_config line 51: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0
    18. debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
    19. debug2: checking match for 'final all' host 192.168.0.101 originally 192.168.0.101
    20. debug3: /etc/ssh/ssh_config.d/05-redhat.conf line 3: matched 'final'
    21. debug2: match found
    22. debug3: /etc/ssh/ssh_config.d/05-redhat.conf line 5: Including file /etc/crypto-policies/back-ends/openssh.config depth 1
    23. debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
    24. debug3: gss kex names ok: [gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1-,gss-group1-sha1-]
    25. debug3: kex names ok: [curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1]
    26. debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
    27. debug2: ssh_connect_direct
    28. debug1: Connecting to 192.168.0.101 [192.168.0.101] port 22.
    29. debug1: Connection established.
    30. debug1: identity file /home/test/.ssh/id_rsa type 0
    31. debug1: identity file /home/test/.ssh/id_rsa-cert type -1
    32. debug1: identity file /home/test/.ssh/id_dsa type -1
    33. debug1: identity file /home/test/.ssh/id_dsa-cert type -1
    34. debug1: identity file /home/test/.ssh/id_ecdsa type -1
    35. debug1: identity file /home/test/.ssh/id_ecdsa-cert type -1
    36. debug1: identity file /home/test/.ssh/id_ecdsa_sk type -1
    37. debug1: identity file /home/test/.ssh/id_ecdsa_sk-cert type -1
    38. debug1: identity file /home/test/.ssh/id_ed25519 type -1
    39. debug1: identity file /home/test/.ssh/id_ed25519-cert type -1
    40. debug1: identity file /home/test/.ssh/id_ed25519_sk type -1
    41. debug1: identity file /home/test/.ssh/id_ed25519_sk-cert type -1
    42. debug1: identity file /home/test/.ssh/id_xmss type -1
    43. debug1: identity file /home/test/.ssh/id_xmss-cert type -1
    44. debug1: Local version string SSH-2.0-OpenSSH_8.2
    45. debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2
    46. debug1: match: OpenSSH_8.2 pat OpenSSH* compat 0x04000000
    47. debug2: fd 4 setting O_NONBLOCK
    48. debug1: Authenticating to 192.168.0.101:22 as 'test'
    49. debug3: hostkeys_foreach: reading file "/home/test/.ssh/known_hosts"
    50. debug3: record_hostkey: found key type ECDSA in file /home/test/.ssh/known_hosts:9
    51. debug3: load_hostkeys: loaded 1 keys from 192.168.0.101
    52. debug3: order_hostkeyalgs: have matching best-preference key type ecdsa-sha2-nistp256-cert-v01@openssh.com, using HostkeyAlgorithms verbatim
    53. debug3: send packet: type 20
    54. debug1: SSH2_MSG_KEXINIT sent
    55. debug3: receive packet: type 20
    56. debug1: SSH2_MSG_KEXINIT received
    57. debug2: local client KEXINIT proposal
    58. debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1,ext-info-c
    59. debug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com,ssh-ed25519,sk-ssh-ed25519@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa
    60. debug2: ciphers ctos: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc
    61. debug2: ciphers stoc: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc
    62. debug2: MACs ctos: hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha1,umac-128@openssh.com,hmac-sha2-512
    63. debug2: MACs stoc: hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha1,umac-128@openssh.com,hmac-sha2-512
    64. debug2: compression ctos: none,zlib@openssh.com,zlib
    65. debug2: compression stoc: none,zlib@openssh.com,zlib
    66. debug2: languages ctos:
    67. debug2: languages stoc:
    68. debug2: first_kex_follows 0
    69. debug2: reserved 0
    70. debug2: peer server KEXINIT proposal
    71. debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256
    72. debug2: host key algorithms: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519
    73. debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com
    74. debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com
    75. debug2: MACs ctos: hmac-sha2-512,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha2-256-etm@openssh.com
    76. debug2: MACs stoc: hmac-sha2-512,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha2-256-etm@openssh.com
    77. debug2: compression ctos: none,zlib@openssh.com
    78. debug2: compression stoc: none,zlib@openssh.com
    79. debug2: languages ctos:
    80. debug2: languages stoc:
    81. debug2: first_kex_follows 0
    82. debug2: reserved 0
    83. debug1: kex: algorithm: curve25519-sha256
    84. debug1: kex: host key algorithm: ecdsa-sha2-nistp256
    85. debug1: kex: server->client cipher: aes256-gcm@openssh.com MAC: <implicit> compression: none
    86. debug1: kex: client->server cipher: aes256-gcm@openssh.com MAC: <implicit> compression: none
    87. debug1: kex: curve25519-sha256 need=32 dh_need=32
    88. debug1: kex: curve25519-sha256 need=32 dh_need=32
    89. debug3: send packet: type 30
    90. debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
    91. debug3: receive packet: type 31
    92. debug1: Server host key: ecdsa-sha2-nistp256 SHA256:xZRYT7h3RsY4d0oJEcOJ6fVcR1dPkXL4y6N+CQ2v9R8
    93. debug3: hostkeys_foreach: reading file "/home/test/.ssh/known_hosts"
    94. debug3: record_hostkey: found key type ECDSA in file /home/test/.ssh/known_hosts:9
    95. debug3: load_hostkeys: loaded 1 keys from 192.168.0.101
    96. debug1: Host '192.168.0.101' is known and matches the ECDSA host key.
    97. debug1: Found key in /home/test/.ssh/known_hosts:9
    98. debug3: send packet: type 21
    99. debug2: set_newkeys: mode 1
    100. debug1: rekey out after 4294967296 blocks
    101. debug1: SSH2_MSG_NEWKEYS sent
    102. debug1: expecting SSH2_MSG_NEWKEYS
    103. debug3: receive packet: type 21
    104. debug1: SSH2_MSG_NEWKEYS received
    105. debug2: set_newkeys: mode 0
    106. debug1: rekey in after 4294967296 blocks
    107. debug1: Will attempt key: /home/test/.ssh/id_rsa RSA SHA256:tCwCdkILafCNjTDeB5Ci/XNv1d2XF5UGtlHXYM8Frtg
    108. debug1: Will attempt key: /home/test/.ssh/id_dsa
    109. debug1: Will attempt key: /home/test/.ssh/id_ecdsa
    110. debug1: Will attempt key: /home/test/.ssh/id_ecdsa_sk
    111. debug1: Will attempt key: /home/test/.ssh/id_ed25519
    112. debug1: Will attempt key: /home/test/.ssh/id_ed25519_sk
    113. debug1: Will attempt key: /home/test/.ssh/id_xmss
    114. debug2: pubkey_prepare: done
    115. debug3: send packet: type 5
    116. debug3: receive packet: type 7
    117. debug1: SSH2_MSG_EXT_INFO received
    118. debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com>
    119. debug3: receive packet: type 6
    120. debug2: service_accept: ssh-userauth
    121. debug1: SSH2_MSG_SERVICE_ACCEPT received
    122. debug3: send packet: type 50
    123. debug3: receive packet: type 53
    124. debug3: input_userauth_banner
    125. Authorized users only. All activities may be monitored and reported.
    126. debug3: receive packet: type 51
    127. debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
    128. debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password
    129. debug3: preferred gssapi-with-mic,publickey,keyboard-interactive,password
    130. debug3: authmethod_lookup gssapi-with-mic
    131. debug3: remaining preferred: publickey,keyboard-interactive,password
    132. debug3: authmethod_is_enabled gssapi-with-mic
    133. debug1: Next authentication method: gssapi-with-mic
    134. debug1: Unspecified GSS failure. Minor code may provide more information
    135. No Kerberos credentials available: No KCM server found
    136. debug1: Unspecified GSS failure. Minor code may provide more information
    137. No Kerberos credentials available: No KCM server found
    138. debug2: we did not send a packet, disable method
    139. debug3: authmethod_lookup publickey
    140. debug3: remaining preferred: keyboard-interactive,password
    141. debug3: authmethod_is_enabled publickey
    142. debug1: Next authentication method: publickey
    143. debug1: Offering public key: /home/test/.ssh/id_rsa RSA SHA256:tCwCdkILafCNjTDeB5Ci/XNv1d2XF5UGtlHXYM8Frtg
    144. debug3: send packet: type 50
    145. debug2: we sent a publickey packet, wait for reply
    146. debug3: receive packet: type 51
    147. debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
    148. debug1: Trying private key: /home/test/.ssh/id_dsa
    149. debug3: no such identity: /home/test/.ssh/id_dsa: No such file or directory
    150. debug1: Trying private key: /home/test/.ssh/id_ecdsa
    151. debug3: no such identity: /home/test/.ssh/id_ecdsa: No such file or directory
    152. debug1: Trying private key: /home/test/.ssh/id_ecdsa_sk
    153. debug3: no such identity: /home/test/.ssh/id_ecdsa_sk: No such file or directory
    154. debug1: Trying private key: /home/test/.ssh/id_ed25519
    155. debug3: no such identity: /home/test/.ssh/id_ed25519: No such file or directory
    156. debug1: Trying private key: /home/test/.ssh/id_ed25519_sk
    157. debug3: no such identity: /home/test/.ssh/id_ed25519_sk: No such file or directory
    158. debug1: Trying private key: /home/test/.ssh/id_xmss
    159. debug3: no such identity: /home/test/.ssh/id_xmss: No such file or directory
    160. debug2: we did not send a packet, disable method
    161. debug3: authmethod_lookup password
    162. debug3: remaining preferred: ,password
    163. debug3: authmethod_is_enabled password
    164. debug1: Next authentication method: password
    165. test@192.168.0.101's password:

     (6)最后排查是普通用户的家目录权限不对导致

    1. [root@localhost ~]# ll /home
    2. 总用量 56
    3. drwxr-xr-x 6 root 103 627 11:57 .
    4. dr-xr-xr-x. 21 root 4096 831 14:27 ..
    5. drwxrwxrwx 8 test 182 91 16:36 test

    (7)修改权限后解决

    [root@localhost ~]# chmod 700 /home/test
  • 相关阅读:
    计算机网络(自顶向下方法)-传输层
    数据结构与算法(C语言版)P1---算法效率
    玩转Android10源码开发定制(二)之基于Pixel 3手机超级详细演示recovery刷机
    三相智能电表逆相序的原因及解决方法
    Android 模拟点击
    月影下的时光机:Python中的日期、时间、农历、节气和时区探秘
    人工智能 – Artificial intelligence | AI,是什么?
    linux系统中三个重要的结构体
    程序媛的mac修炼手册-- 2024如何彻底卸载Python
    k8s实践记录
  • 原文地址:https://blog.csdn.net/qq_25868251/article/details/132626675