V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
lemual
V2EX  ›  问与答

Linux 普通用户配置 ssh 免密登录不起作用, root 用户可以实现免密登录

  •  1
     
  •   lemual · 2018-04-01 00:31:22 +08:00 · 6631 次点击
    这是一个创建于 2435 天前的主题,其中的信息可能已经有所发展或是发生改变。

    普通用户 hexo home 文件下的.ssh/authorized_keys 已经配置好 .ssh 文件权限以及 authorized_keys 权限如下: drwx------ 2 hexo hexo 4096 Apr 1 00:01 .ssh authorized_keys -rw------- 1 root root 401 Mar 13 17:41 authorized_keys -rw-r--r-- 1 hexo hexo 171 Apr 1 00:01 known_hosts 打印的 log 如下,哪位大神能给指点一下: λ ssh [email protected] [email protected]'s password: Last login: Sun Apr 1 00:02:00 2018 from 127.0.0.1 [hexo@VM_28_59_centos ~]$ sudo tail /var/log/secure -n 20 [sudo] password for hexo: Apr 1 00:08:49 VM_28_59_centos sshd[25151]: Disconnected from 58.218.198.167 port 11592 [preauth] Apr 1 00:08:49 VM_28_59_centos sshd[25151]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=58.218.198.167 user=root Apr 1 00:08:50 VM_28_59_centos su: pam_unix(su:session): session closed for user root Apr 1 00:08:57 VM_28_59_centos sshd[24288]: Received disconnect from 223.3.71.151 port 7153:11: disconnected by user Apr 1 00:08:57 VM_28_59_centos sshd[24288]: Disconnected from 223.3.71.151 port 7153 Apr 1 00:08:57 VM_28_59_centos sshd[24285]: pam_unix(sshd:session): session closed for user hexo Apr 1 00:09:04 VM_28_59_centos sshd[25161]: Accepted password for hexo from 223.3.71.151 port 7608 ssh2 Apr 1 00:09:04 VM_28_59_centos sshd[25161]: pam_unix(sshd:session): session opened for user hexo by (uid=0) Apr 1 00:09:05 VM_28_59_centos sshd[25161]: pam_lastlog(sshd:session): corruption detected in /var/log/btmp Apr 1 00:09:15 VM_28_59_centos sshd[25232]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=58.218.198.167 user=root Apr 1 00:09:15 VM_28_59_centos sshd[25232]: pam_succeed_if(sshd:auth): requirement "uid >= 1000" not met by user "root" Apr 1 00:09:17 VM_28_59_centos sshd[25232]: Failed password for root from 58.218.198.167 port 60487 ssh2 Apr 1 00:09:17 VM_28_59_centos sshd[25232]: pam_succeed_if(sshd:auth): requirement "uid >= 1000" not met by user "root" Apr 1 00:09:20 VM_28_59_centos sshd[25232]: Failed password for root from 58.218.198.167 port 60487 ssh2 Apr 1 00:09:20 VM_28_59_centos sshd[25232]: pam_succeed_if(sshd:auth): requirement "uid >= 1000" not met by user "root" Apr 1 00:09:22 VM_28_59_centos sshd[25232]: Failed password for root from 58.218.198.167 port 60487 ssh2 Apr 1 00:09:22 VM_28_59_centos sshd[25232]: Received disconnect from 58.218.198.167 port 60487:11: [preauth] Apr 1 00:09:22 VM_28_59_centos sshd[25232]: Disconnected from 58.218.198.167 port 60487 [preauth] Apr 1 00:09:22 VM_28_59_centos sshd[25232]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=58.218.198.167 user=root Apr 1 00:09:23 VM_28_59_centos sudo: hexo : TTY=pts/0 ; PWD=/home/hexo ; USER=root ; COMMAND=/bin/tail /var/log/secure -n 20

    8 条回复    2018-04-02 15:51:38 +08:00
    Remember
        1
    Remember  
       2018-04-01 02:18:24 +08:00
    排版很重要.
    msg7086
        2
    msg7086  
       2018-04-01 02:32:11 +08:00
    看看 sshd_config 里是否允许了 root 登录。
    nieyujiang
        3
    nieyujiang  
       2018-04-01 04:29:26 +08:00
    你这个排版.......
    congeec
        4
    congeec  
       2018-04-01 07:05:15 +08:00 via iPhone
    ........排版就不吐槽了
    我一般靠 ssh --verbose 定位问题
    wqzjk393
        5
    wqzjk393  
       2018-04-01 07:10:29 +08:00 via iPhone
    我都是自己创建一个高权限账户,然后设置这个账户使用 sudo 时候免密码。然后平时操作实在需要 root 权限时候 sudo。没办法,vps 的 root 账户密码是很长一串随机字符串根本记不住,而且还大小写混合特别容易打错
    lemual
        6
    lemual  
    OP
       2018-04-01 10:40:31 +08:00
    @congeec 发之前排版是好的,发出来就成这样了。问题已解决,文件权限问题。
    lemual
        7
    lemual  
    OP
       2018-04-01 10:41:22 +08:00
    问题已解决,文件权限问题。.ssh 权限设置为 700,authorized_keys 设置为 600 即可
    julyclyde
        8
    julyclyde  
       2018-04-02 15:51:38 +08:00
    你最开始就是 700、600 的权限啊
    关键 authorized_keys 的 owner,在最开始不正确
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2553 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 04:59 · PVG 12:59 · LAX 20:59 · JFK 23:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.