• 新服务器sudo与权限分配<NIOT>


    0,生成RSA公钥秘钥

    a,源主机:#ssh-keygen -t rsa

    1,拷贝公钥到authorized_keys文件里面

    a,源主机:#ssh-copy-id -i /root/.ssh/id_rsa.pub root@123.57.1.1

    b,目的主机:#vim /root/.ssh/authorized_keys

    c,目的主机:#cat id_rsa.pub > /root/.ssh/authorized_keys

    d,目的主机:#chmod 600 .ssh/authorized_keys

    2,测试rsa

    a,源主机:#ssh root@123.57.1.1

    3,添加普通用户,附加到wheel组(默认带sudo权限)

    a,目的主机:#useradd -G wheel username

    b,目的主机:#passwd username

    c,目的主机:#id username

    4,编辑sudoers,禁止wheel组修改其他人密码
    a,目的主机:#visudo

    修改%wheel ALL=(ALL) ALL 为 %wheel ALL=(ALL) NOPASSWD: ALL,!/usr/bin/passwd [A-Za-z]*

    5、编辑ssd_config,禁止root通过ssh密码登陆

    a,目标主机:#vim /etc/ssh/sshd_config (第48行)

    修改#PermitRootLogin yes 为 PermitRootLogin without-password

    b,重启sshd服务,目标主机:#service sshd restart,或者#systemctl restart sshd.service

    或者#service ssh restart(ubuntu)

    <完>

  • 相关阅读:
    Django入门
    html语言
    elasticsearch基本接口使用
    linux随笔
    mysql基础操作
    mysql存储引擎
    MySQL字符集
    并发编程之多进程
    异常处理
    socket编程
  • 原文地址:https://www.cnblogs.com/fatt/p/4995027.html
Copyright © 2020-2023  润新知