ssh localhost 登陆时出现的密码问题

来源:互联网 发布:制作柏拉图的软件 编辑:程序博客网 时间:2024/05/21 10:51
    ssh localhost无密码登陆,如果遇到下面这种情况,一般的解决办法是
$ exit                           # 退出刚才的 ssh localhost$ cd ~/.ssh/ # 若没有该目录,请先执行一次ssh localhost$ ssh-keygen -t rsa              # 会有提示,都按回车就可以$ cat id_rsa.pub >> authorized_keys  # 加入授权



    如果上面方法成功了,则再用ssh localhost登陆时就会出现:

    但是如果出现的不是这种情况,而是再让你输入输入一次密码,

    这时候,需要更改一下文件权限:

$ chmod 600 ~/.ssh/authorized_keys
   细心的你可能会发现,在上面这个图中,我用了chmod 664 ~/.ssh/authorized_keys命令,更改了authorized_keys文件的权限,因为我之前是可以正常无密码ssh localhost登陆的,更改权限后就把要说明的问题体现出来了。出现上述问题时因为这个文件需要不同的权限来阻止其他人对该文件的读写。因此用的是600而不是664,如果是664,则系统认为时不安全的,这时候就要输入密码了。
The reason the file needs slightly different permissions to prevent anyone except the file owner, reading or writing to that file. Hence 600 rather than 644. If this is not the case ssh will ignore the file, as its considered unsafe.


0 1
原创粉丝点击