主机名 | IP | CPU | 内存 | 磁盘 | 部署 |
---|---|---|---|---|---|
node1 | 10.10.200.211 | 2核 | 4GB | 50GB | — |
node2 | 10.10.200.212 | 2核 | 4GB | 50GB | — |
node3 | 10.10.200.213 | 2核 | 4GB | 50GB | — |
三台服务器中,创建普通账户,使用 ssh-keygen 创建秘钥,配置好免密登录后无效,排查发现错误 "we did not send a packet, disable method"。
[root@node1 ~]# useradd dev
[root@node1 ~]# echo "123456" | passwd --stdin dev
Changing password for user dev.
passwd: all authentication tokens updated successfully.
[root@node1 ~]# su - dev
[dev@node1 ~]$ ssh-keygen -t rsa
[root@node1 ~]# cat ~/.ssh/id_rsa.pub
[dev@node1 ~]$ touch ~/.ssh/authorized_keys
[dev@node1 ~]$ cat ~/.ssh/authorized_keys
[root@node1 ~]# systemctl restart sshd
[dev@node1 ~]$ ssh -vvv [email protected]
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:1000)
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:1000)
debug2: we did not send a packet, disable method
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
[dev@node1 ~]$ ls -la ~
total 20
drwx------. 3 dev dev 111 Aug 26 18:53 .
drwxr-xr-x. 3 root root 17 Aug 26 18:43 ..
-rw-------. 1 dev dev 185 Aug 26 18:53 .bash_history
-rw-r--r--. 1 dev dev 18 Aug 3 2016 .bash_logout
-rw-r--r--. 1 dev dev 193 Aug 3 2016 .bash_profile
-rw-r--r--. 1 dev dev 231 Aug 3 2016 .bashrc
drwx------. 2 dev dev 80 Aug 26 19:00 .ssh
-rw-------. 1 dev dev 678 Aug 26 18:52 .viminfo
[dev@node1 ~]$ ls -la ~/.ssh/
total 16
drwx------. 2 dev dev 80 Aug 26 19:00 .
drwx------. 3 dev dev 111 Aug 26 18:53 ..
-rw-rw-r--. 1 dev dev 1173 Aug 26 18:52 authorized_keys
-rw-------. 1 dev dev 1679 Aug 26 18:49 id_rsa
-rw-r--r--. 1 dev dev 391 Aug 26 18:49 id_rsa.pub
-rw-r--r--. 1 dev dev 175 Aug 26 19:00 known_hosts
[dev@node1 ~]$ cat ~/.ssh/known_hosts
10.10.200.211 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOScSoZznOz0Q3qpG8ShLUWAu2523dANKL9Xnr4vM3ljzR+gberesxB+UK+nuEvak/ufCpsMWrprmgLG9POGB/Y=
[dev@node1 ~]$ chmod 0755 ~
[dev@node1 ~]$ chmod 700 ~/.ssh
[dev@node1 ~]$ chmod 600 ~/.ssh/authorized_keys
[dev@node1 ~]$ ls -la ~
total 20
drwxr-xr-x. 3 dev dev 111 Aug 26 18:53 .
drwxr-xr-x. 3 root root 17 Aug 26 18:43 ..
-rw-------. 1 dev dev 185 Aug 26 18:53 .bash_history
-rw-r--r--. 1 dev dev 18 Aug 3 2016 .bash_logout
-rw-r--r--. 1 dev dev 193 Aug 3 2016 .bash_profile
-rw-r--r--. 1 dev dev 231 Aug 3 2016 .bashrc
drwx------. 2 dev dev 80 Aug 26 19:09 .ssh
-rw-------. 1 dev dev 678 Aug 26 18:52 .viminfo
[dev@node1 ~]$ ls -la ~/.ssh/
total 16
drwx------. 2 dev dev 80 Aug 26 19:09 .
drwxr-xr-x. 3 dev dev 111 Aug 26 18:53 ..
-rw-------. 1 dev dev 1173 Aug 26 18:52 authorized_keys
-rw-------. 1 dev dev 1679 Aug 26 18:49 id_rsa
-rw-r--r--. 1 dev dev 391 Aug 26 18:49 id_rsa.pub
-rw-r--r--. 1 dev dev 543 Aug 26 19:09 known_hosts
[dev@node1 ~]$ cat ~/.ssh/known_hosts
node1,10.10.200.211 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOScSoZznOz0Q3qpG8ShLUWAu2523dANKL9Xnr4vM3ljzR+gberesxB+UK+nuEvak/ufCpsMWrprmgLG9POGB/Y=
node2,10.10.200.212 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOScSoZznOz0Q3qpG8ShLUWAu2523dANKL9Xnr4vM3ljzR+gberesxB+UK+nuEvak/ufCpsMWrprmgLG9POGB/Y=
node3,10.10.200.213 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOScSoZznOz0Q3qpG8ShLUWAu2523dANKL9Xnr4vM3ljzR+gberesxB+UK+nuEvak/ufCpsMWrprmgLG9POGB/Y=
.ssh 目录的权限必须是 700
.ssh/authorized_keys 文件权限必须是 600
存放远程免密登录的公钥,主要通过这个文件记录多台机器的公钥。
[dev@node1 ~]$ cat ~/.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD8BjRJKEPYgJsJ1AFei8tflMgTXs6I/BNMuWjIq6WuWGxSbnkoR7TFwnd0E8rY1JvAhS8g6Nkbd4ObIeQNCIVGH8VHjirABRha3T0IAA3zMvF1touaLicUe1ntM4M/aE96B+4sGleWK2AxbKtvmuNU3Q+WAsAaEuvLlIoa1rHeQxCYhmuTA8Jx5UTe0+ozHivMmYHbPGd6SBwYIU4/s7pUTRkjX77tJes0XPvyp13p+uawhFXJCd0AFdGKY7DF47mtr4gu8Pw+s5SZOn11XIsZ+cVq02gzUgjCgU/1FphV6uzhAy7qgqQ7oJGF7D5QlisaBifY1ypQBJU9ROtsIclD dev@node1
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDEQOrCDXpPB7HNnQWgIs213FmgqLMJUNylsHw0fNTfRDHE+GTex0vaBJGCvTq72Reia2PbA8ZkXgls+BH4KEk4p/9VoStbmbOY9Q/43OK6b33uyFPI2ilhlnYmwgW8l3btJPlzB1Mo0Vw+xRFr5K8uGPWEw8re3LQklGgu4BdHc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FSB58tT0fXvcpVl1czRF+Tt+h4eySNrG
P2l+CRe+XzC+1/dvVS/sGlRPUUgldeyIBPi3/KkJZ+rbUcOgwAzf46U=
-----END RSA PRIVATE KEY-----
生成的公钥文件
[dev@node1 ~]$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD8BjRJKEPYgJsJ1AFei8tflMgTXs6I/BNMuWjIq6WuWGxSbnkoR7TFwnd0E8rY1JvAhS8g6Nkbd4ObIeQNCIVGH8VHjirABRha3T0IAA3zMvF1touaLicUe1ntM4M/aE96B+4sGleWK2AxbKtvmuNU3Q+WAsAaEuvLlIoa1rHeQxCYhmuTA8Jx5UTe0+ozHivMmYHbPGd6SBwYIU4/s7pUTRkjX77tJes0XPvyp13p+uawhFXJCd0AFdGKY7DF47mtr4gu8Pw+s5SZOn11XIsZ+cVq02gzUgjCgU/1FphV6uzhAy7qgqQ7oJGF7D5QlisaBifY1ypQBJU9ROtsIclD dev@node1
已知的主机公钥清单
[dev@node1 ~]$ cat ~/.ssh/known_hosts
node1,10.10.200.211 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOScSoZznOz0Q3qpG8ShLUWAu2523dANKL9Xnr4vM3ljzR+gberesxB+UK+nuEvak/ufCpsMWrprmgLG9POGB/Y=
node2,10.10.200.212 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOScSoZznOz0Q3qpG8ShLUWAu2523dANKL9Xnr4vM3ljzR+gberesxB+UK+nuEvak/ufCpsMWrprmgLG9POGB/Y=
node3,10.10.200.213 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOScSoZznOz0Q3qpG8ShLUWAu2523dANKL9Xnr4vM3ljzR+gberesxB+UK+nuEvak/ufCpsMWrprmgLG9POGB/Y=