如何创建使用仅密钥身份验证的 ssh 登录的用户?

如何创建使用仅密钥身份验证的 ssh 登录的用户?

我正在尝试设置一个新用户,该用户将只能使用密钥登录。此外,我需要将其主目录更改为 /var/www/website。以下是我执行的步骤和结果

  1. 创建了一个用户useradd mark
  2. 使用 puttygen(ssh-2 rsa)在 win 机器上生成密钥,添加密钥密码,将私钥保存到 .ppk 文件。
  3. 将公钥复制到服务器的 authorized_keys 文件中。它被复制到一行中(我发现复制到多行中可能会导致问题)

在服务器上,只允许使用密钥登录。当我尝试通过 winscp 使用新用户和新密钥连接时,我收到的错误是

No supported authentication methods available (server sent: publickey,gssapi-keyex,gssapi-with-mic).
Server refused our key.
Authentication failed.

我是谁;root

ls -ld /home/mark /home/mark/.ssh /home/mark/.ssh/authorized_keys;

drwxrwxrwx 3 mark mark 4096 Nov 19 23:39 /home/mark drwxrwxrwx 2 mark mark 4096 Nov 19 23:41 /home/mark/.ssh -rwxrwxrwx 1 mark mark 401 Nov 20 00:13 /home/mark/.ssh/authorized_keys

一次尝试的完整日志堆栈 Nov 20 16:33:15 HOSTNAME sshd[12419]: debug1: userauth-request for user mark service ssh-connection method publickey Nov 20 16:33:15 HOSTNAME sshd[12419]: debug1: attempt 1 failures 1 Nov 20 16:33:15 HOSTNAME sshd[12419]: debug2: input_userauth_request: try method publickey Nov 20 16:33:15 HOSTNAME sshd[12419]: debug1: test whether pkalg/pkblob are acceptable Nov 20 16:33:15 HOSTNAME sshd[12419]: debug3: mm_key_allowed entering Nov 20 16:33:15 HOSTNAME sshd[12419]: debug3: mm_request_send entering: type 21 Nov 20 16:33:15 HOSTNAME sshd[12419]: debug3: mm_key_allowed: waiting for MONITOR_ANS_KEYALLOWED Nov 20 16:33:15 HOSTNAME sshd[12419]: debug3: mm_request_receive_expect entering: type 22 Nov 20 16:33:15 HOSTNAME sshd[12419]: debug3: mm_request_receive entering Nov 20 16:33:15 HOSTNAME sshd[12418]: debug3: monitor_read: checking request 21 Nov 20 16:33:15 HOSTNAME sshd[12418]: debug3: mm_answer_keyallowed entering Nov 20 16:33:15 HOSTNAME sshd[12418]: debug3: mm_answer_keyallowed: key_from_blob: 0x7fb00ff9ebc0 Nov 20 16:33:15 HOSTNAME sshd[12418]: debug1: temporarily_use_uid: 508/508 (e=0/0) Nov 20 16:33:15 HOSTNAME sshd[12418]: debug1: trying public key file /home/mark/.ssh/authorized_keys Nov 20 16:33:15 HOSTNAME sshd[12418]: debug1: Could not open authorized keys '/home/mark/.ssh/authorized_keys': Permission denied Nov 20 16:33:15 HOSTNAME sshd[12418]: debug1: restore_uid: 0/0 Nov 20 16:33:15 HOSTNAME sshd[12418]: debug1: temporarily_use_uid: 508/508 (e=0/0) Nov 20 16:33:15 HOSTNAME sshd[12418]: debug1: trying public key file /home/mark/.ssh/authorized_keys Nov 20 16:33:15 HOSTNAME sshd[12418]: debug1: Could not open authorized keys '/home/mark/.ssh/authorized_keys': Permission denied Nov 20 16:33:15 HOSTNAME sshd[12418]: debug1: restore_uid: 0/0 Nov 20 16:33:15 HOSTNAME sshd[12418]: Failed publickey for mark from 178.148.168.147 port 62172 ssh2 Nov 20 16:33:15 HOSTNAME sshd[12418]: debug3: mm_answer_keyallowed: key 0x7fb00ff9ebc0 is not allowed Nov 20 16:33:15 HOSTNAME sshd[12418]: debug3: mm_request_send entering: type 22 Nov 20 16:33:15 HOSTNAME sshd[12418]: debug3: mm_request_receive entering Nov 20 16:33:15 HOSTNAME sshd[12419]: debug2: userauth_pubkey: authenticated 0 pkalg ssh-rsa Nov 20 16:33:15 HOSTNAME sshd[12419]: debug3: Wrote 96 bytes for a total of 1965 Nov 20 16:33:17 HOSTNAME sshd[12419]: Received disconnect from IP : 13: User request Nov 20 16:33:17 HOSTNAME sshd[12419]: debug1: do_cleanup Nov 20 16:33:17 HOSTNAME sshd[12419]: debug3: PAM: sshpam_thread_cleanup entering Nov 20 16:33:17 HOSTNAME sshd[12419]: debug3: mm_request_send entering: type 80 Nov 20 16:33:17 HOSTNAME sshd[12419]: debug3: mm_request_receive_expect entering: type 81 Nov 20 16:33:17 HOSTNAME sshd[12419]: debug3: mm_request_receive entering Nov 20 16:33:17 HOSTNAME sshd[12418]: debug3: monitor_read: checking request 80 Nov 20 16:33:17 HOSTNAME sshd[12418]: debug3: mm_request_send entering: type 81 Nov 20 16:33:17 HOSTNAME sshd[12418]: debug3: mm_request_receive entering Nov 20 16:33:17 HOSTNAME sshd[12418]: debug1: do_cleanup Nov 20 16:33:17 HOSTNAME sshd[12418]: debug1: PAM: cleanup Nov 20 16:33:17 HOSTNAME sshd[12418]: debug3: PAM: sshpam_thread_cleanup entering Nov 20 16:33:22 HOSTNAME sshd[11630]: debug3: Received SSH2_MSG_IGNORE Nov 20 16:33:52 HOSTNAME sshd[11630]: debug3: Received SSH2_MSG_IGNORE Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 80 bytes for a total of 7077 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 96 bytes for a total of 7173 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 4160 bytes for a total of 11333 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 4160 bytes for a total of 15493 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 4160 bytes for a total of 19653 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 8272 bytes for a total of 27925 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 4160 bytes for a total of 32085 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 48533 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 64981 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 81429 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 25892 bytes for a total of 107321 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 35040 bytes for a total of 142361 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 40880 bytes for a total of 183241 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 43800 bytes for a total of 227041 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 35316 bytes for a total of 262357 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 278805 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 295253 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 311701 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 328149 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 344597 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 361045 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 32896 bytes for a total of 393941 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 410389 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 426837 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 443285 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 459733 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 476181 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 492629 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 509077 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 525525 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 541973 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 558421 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 574869 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 591317 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 607765 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 624213 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 640661 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 657109 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 32896 bytes for a total of 690005 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 706453 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 722901 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 739349 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 755797 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 772245 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 788693 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 805141 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 821589 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 838037 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 854485 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 870933 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 887381 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 903829 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 920277 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 936725 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 953173 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 969621 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 986069 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1002517 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1018965 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1035413 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1051861 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1068309 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1084757 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1101205 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1117653 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1134101 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1150549 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1166997 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1183445 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1199893 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1216341 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1232789 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1249237 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1265685 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1282133 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1298581 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1315029 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1331477 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1347925 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1364373 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1380821 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1397269 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1413717 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1430165 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1446613 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1463061 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1479509 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1495957 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1512405 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1528853 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1545301 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1561749 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1578197 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1594645 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1611093 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1627541 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1643989 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1660437 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1676885 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1693333 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1709781 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1726229 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1742677 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1759125 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1775573 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1792021 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1808469 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1824917 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1841365 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1857813 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1874261 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1890709 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1907157 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1923605 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1940053 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1956501 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1972949 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 1989397 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2005845 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2022293 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2038741 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2055189 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2071637 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2088085 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2104533 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2120981 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2137429 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2153877 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2170325 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2186773 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2203221 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2219669 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2236117 Nov 20 16:33:53 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2252565 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2269013 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2285461 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2301909 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2318357 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2334805 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2351253 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2367701 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2384149 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2400597 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2417045 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2433493 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2449941 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2466389 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2482837 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2499285 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2515733 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2532181 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2548629 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2565077 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2581525 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2597973 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2614421 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2630869 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2647317 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2663765 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2680213 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2696661 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2713109 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2729557 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2746005 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2762453 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2778901 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2795349 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2811797 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2828245 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2844693 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2861141 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2877589 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2894037 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2910485 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2926933 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2943381 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2959829 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2976277 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 2992725 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 3009173 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 3025621 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 3042069 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 3058517 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 3074965 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 3091413 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 3107861 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 3124309 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 3140757 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 3157205 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 3173653 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 3190101 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 3206549 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 3222997 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 3239445 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 3255893 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 3272341 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 3288789 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 3305237 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 3321685 Nov 20 16:33:54 HOSTNAME sshd[12187]: debug3: Wrote 16448 bytes for a total of 3338133

有任何想法吗?

答案1

您的描述似乎不错,但您可能以错误的方式粘贴了密钥(某些拼写错误或缺少字符)。为了帮助您诊断问题,您可以执行以下操作:

编辑配置文件/etc/ssh/sshd_config,设置日志级别:

LogLevel DEBUG3

然后重新加载 ssh

sudo /etc/init.d/ssh reload

这会增加 ssh 守护进程的日志级别,以便您可以了解发生了什么。/var/log/auth.log尝试登录时,请查看 ssh 日志文件以查找问题。

答案2

检查/var/log/secure错误sshd。由于用户主目录、.ssh目录或authorized_keys文件本身的所有权和/或权限不正确,可能会出现错误,因此sshd将忽略该文件。
还请检查AuthorizedKeysFile指令/etc/ssh/sshd_config:sshd 可能配置为在其他地方而不是在用户主目录中查找authorized_keys文件。如果是这种情况,则只需将authorized_keys文件放在具有正确所有者和权限的正确位置,然后再试一次。

答案3

抱歉,我忘了您使用了Centos,并且Selinux默认情况下已启用。因此,对于您的情况,您必须允许sshd访问/var路径下的文件夹。以下是Centos 论坛主题描述如何允许sshd访问authorized_keys外部/home文件夹。

相关内容