用ssh免密处理ubuntu@localhost's password:, 但ssh免密失败, 怎么办?

遇到ubuntu@localhost's password:, 不知道密码,很讨厌, 那就免密ssh搞起, 但搞了好几次, ssh免密一直失败,还是提醒ubuntu@localhost's password:, 最后发现是权限的问题, 来看看:

ubuntu@VM-0-15-ubuntu:~$ ssh localhost
Warning: Permanently added 'localhost' (ECDSA) to the list of kNown hosts.
ubuntu@localhost's password: 
Permission denied,please try again.
ubuntu@localhost's password: 
Permission denied,please try again.
ubuntu@localhost's password: 
Permission denied (publickey,password).            // 要密码,不知道, 很蛋疼
ubuntu@VM-0-15-ubuntu:~$ 
ubuntu@VM-0-15-ubuntu:~$ 
ubuntu@VM-0-15-ubuntu:~$ 
ubuntu@VM-0-15-ubuntu:~$ ssh-keygen -t rsa         // 一路enter按下去,不要停
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ubuntu/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/ubuntu/.ssh/id_rsa.
Your public key has been saved in /home/ubuntu/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:HuAsdG85+vxn3RLn5QreR9k/CSclzJnimhRTXjPToi8 ubuntu@VM-0-15-ubuntu
The key's randomart image is:
+---[RSA 2048]----+
|              .  |
|           . * . |
|    . o   o = B  |
|   . + o + + * . |
|    . o S + o o o|
|     . + + E +.o=|
|      . o o o.+B+|
|       o o .oooo*|
|        o..o. o+.|
+----[SHA256]-----+
ubuntu@VM-0-15-ubuntu:~$ 
ubuntu@VM-0-15-ubuntu:~$ 
ubuntu@VM-0-15-ubuntu:~$ 
ubuntu@VM-0-15-ubuntu:~$ cd .ssh 
ubuntu@VM-0-15-ubuntu:~/.ssh$ ls
id_rsa  id_rsa.pub
ubuntu@VM-0-15-ubuntu:~/.ssh$ cat id_rsa.pub >> authorized_keys
ubuntu@VM-0-15-ubuntu:~/.ssh$ ls
authorized_keys  id_rsa  id_rsa.pub
ubuntu@VM-0-15-ubuntu:~/.ssh$ 
ubuntu@VM-0-15-ubuntu:~/.ssh$ 
ubuntu@VM-0-15-ubuntu:~/.ssh$ 
ubuntu@VM-0-15-ubuntu:~/.ssh$ cd ..
ubuntu@VM-0-15-ubuntu:~$ chmod 700 .ssh         // 必须
ubuntu@VM-0-15-ubuntu:~$ chmod 600 .ssh/*       // 必须
ubuntu@VM-0-15-ubuntu:~$ 
ubuntu@VM-0-15-ubuntu:~$ 
ubuntu@VM-0-15-ubuntu:~$ 
ubuntu@VM-0-15-ubuntu:~$ ssh localhost          // 免密进入一层localhost
Warning: Permanently added 'localhost' (ECDSA) to the list of kNown hosts.
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-91-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

Last login: Sat Mar  3 08:51:40 2018 from 222.248.84.42
ubuntu@VM-0-15-ubuntu:~$ 
ubuntu@VM-0-15-ubuntu:~$ 
ubuntu@VM-0-15-ubuntu:~$ 
ubuntu@VM-0-15-ubuntu:~$ ssh localhost         // 免密进入二层localhost
Warning: Permanently added 'localhost' (ECDSA) to the list of kNown hosts.
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-91-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

Last login: Sat Mar  3 08:56:32 2018 from 127.0.0.1
ubuntu@VM-0-15-ubuntu:~$ 
ubuntu@VM-0-15-ubuntu:~$ 
ubuntu@VM-0-15-ubuntu:~$ 
ubuntu@VM-0-15-ubuntu:~$ exit                  // 退出二层localhost
logout
Connection to localhost closed.
ubuntu@VM-0-15-ubuntu:~$ exit
logout
Connection to localhost closed.                // 退出一层localhost,回归到原来的shell
ubuntu@VM-0-15-ubuntu:~$

爬山去了, 多锻炼, 减减肥。

相关文章

目录前言一、创建Hadoop用户二、更新apt和安装Vim编辑器三、...
原文连接:https://www.cnblogs.com/yasmi/p/5192694.html ...
电脑重启后,打开VirtualBox,发现一直用的虚拟机莫名的消失...
参见:https://blog.csdn.net/weixin_38883338/article/deta...
Ubuntu 18.04 LTS 已切换到 Netplan 来配置网络接口。Netpla...
介绍每个 Web 服务都可以通过特定的 URL 在 Internet 上访问...