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

前端之家收集整理的这篇文章主要介绍了用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:~$

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

猜你在找的Ubuntu相关文章