ssh无密登陆localhost

1、安装ssh
sudo apt-get ssh install

2、生成密钥
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
3、将公钥放入认证文件
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
4、修改文件权限
sudo chmod 700 ~/.ssh
sudo chmod 600 ~/.ssh/id_rsa
sudo chmod 600 ~/.ssh/id_rsa.pub
sudo chmod 644 ~/.ssh/authorized_keys

显示如下:
drwxr-xr-x  2 will will 4096 May 31 22:42 .
drwxr-xr-x 31 will will 4096 May 31 22:22 ..
-rw-------  1 will will  393 May 31 22:42 authorized_keys
-rw-------  1 will will 1679 May 31 22:42 id_rsa
-rw-------  1 will will  393 May 31 22:42 id_rsa.pub
-rw-r--r--  1 will will  666 May 31 08:41 known_hosts

此处假设.ssh的父目录是xxx  .ssh的路径   /home/xxx/.ssh
sudo chmod 755 /home/xxx  (我就是因为没有设置该文件夹的权限弄了很久都没成功!)

5、测试

ssh localhost


xxx@ubuntu:/$ ssh localhost
Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.19.0-25-generic x86_64)
* Documentation:  https://help.ubuntu.com/
361 packages can be updated.
208 updates are security updates.
New release '16.04.2 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
Last login: Wed May 31 22:59:20 2017 from localhost
xxx@ubuntu:~$ exit
logout
Connection to localhost closed.
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值