免密登录问题:
方案1:
修改/etc/ssh/ssh_config文件的配置,以后则不会再出现此问题
最后面添加:
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
然后执行 /etc/init.d/sshd restart
方案2:删除 .ssh/文件
[fanyue@hadoop01 ~]$ rm-rf .ssh/[fanyue@hadoop01 ~]$ ssh localhost
Warning: Permanently added 'localhost'(ECDSA) to the list of known hosts.
fanyue@localhost's password:
Last login: Fri Apr 17 21:18:29 2020
[fanyue@hadoop01 ~]$ exit
登出
Connection to localhost closed.
[fanyue@hadoop01 ~]$ pwd
/home/fanyue
[fanyue@hadoop01 ~]$ cd ~/.ssh/
[fanyue@hadoop01 .ssh]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/fanyue/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/fanyue/.ssh/id_rsa.
Your public key has been saved in /home/fanyue/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:yGTJZk1laqlypRzN9SRsefcqsH4u+0sTC0TUZ3VI/mw fanyue@hadoop01
The key's randomart image is:
+---[RSA 2048]----+|.+Bo...oo||.**++o.= .|| O O....+..|| B B .. o.||. B S .o..E|| o ...o..||.+.|| o...||.*+.|+----[SHA256]-----+[fanyue@hadoop01 .ssh]$ cat id_rsa.pub >> authorized_keys
[fanyue@hadoop01 .ssh]$ chmod 600 ./authorized_keys
[fanyue@hadoop01 .ssh]$ cd ~/.ssh
[fanyue@hadoop01 .ssh]$ ls-l
总用量 12
-rw-------. 1 fanyue fanyue 397 4月 17 21:38 authorized_keys
-rw-------. 1 fanyue fanyue 1675 4月 17 21:38 id_rsa
-rw-r--r--. 1 fanyue fanyue 397 4月 17 21:38 id_rsa.pub
[fanyue@hadoop01 .ssh]$ ssh localhost
Warning: Permanently added 'localhost'(ECDSA) to the list of known hosts.
Last login: Fri Apr 17 21:37:44 2020 from localhost
[fanyue@hadoop01 ~]$ exit
登出