美文网首页我爱编程
sudo root免密码

sudo root免密码

作者: cschen | 来源:发表于2018-03-09 09:19 被阅读0次

    新建了个hadoop用户,想让他sudo切换到root免密码
    终端输入

    nano  /etc/sudoers
    

    ubuntu16.04是以下内容

    #
    # This file MUST be edited with the 'visudo' command as root.
    #
    # Please consider adding local content in /etc/sudoers.d/ instead of 
    # directly modifying this file.
    #
    # See the man page for details on how to write a sudoers file.
    #
    Defaults        env_reset
    Defaults        mail_badpass
    Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
    
    # Host alias specification
    
    # User alias specification
    
    # Cmnd alias specification
    
    # User privilege specification
    root    ALL=(ALL:ALL) ALL
    
    # Members of the admin group may gain root privileges
    %admin ALL=(ALL) ALL
    
    # Allow members of group sudo to execute any command
    %sudo   ALL=(ALL:ALL) ALL
    
    # See sudoers(5) for more information on "#include" directives:
    
    #includedir /etc/sudoers.d
    

    它说不要直接改这个文件,要改就去改/etc/sudoers.d/的。

    cd /etc/sudoers.d/
    ls
    

    看看这个目录有什么

    root@ubuntu03:~# cd  /etc/sudoers.d/
    root@ubuntu03:/etc/sudoers.d# ls
    90-cloud-init-users  README
    

    我这里看到有个90-cloud-init-users
    nano 90-cloud-init-users打开看看
    里面有个ubuntu用户已经是免密码的,在下面加上新增的hadoop用户就OK了。

    # User rules for ubuntu
    ubuntu ALL=(ALL) NOPASSWD:ALL
    hadoop ALL=(ALL) NOPASSWD:ALL
    

    相关文章

      网友评论

        本文标题:sudo root免密码

        本文链接:https://www.haomeiwen.com/subject/hexpfftx.html