码迷,mamicode.com
首页 > 系统相关 > 详细

linux下禁止root远程登录

时间:2019-12-23 19:16:19      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:str   技术   rest   http   sudoer   远程登录   mic   root权限   anywhere   

一、添加和root权限一样的用户

   1、

    adduser admin

    passwd  admin (修改密码)

技术图片

 

 2、修改 /etc/sudoers 文件,找到下面一行,在root下面添加一行,如下所示

  • vim /etc/sudoers 
  • ## Allow root to run any commands anywhere
  • root ALL=(ALL) ALL
  • admin ALL=(ALL) ALL

二、禁止root远程登录

需要编辑/etc/ssh/sshd_config。

vim /etc/ssh/sshd_config    找到 PermitRootLogin

改为 PermitRootLogin no

重启  service sshd restart

你只是禁止了root用户登陆,没有禁止别的用户,先用别的用户登陆,在 su root 切回root用户

切换到root用户还要在输如密码

linux下禁止root远程登录

标签:str   技术   rest   http   sudoer   远程登录   mic   root权限   anywhere   

原文地址:https://www.cnblogs.com/hellohero55/p/12085060.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!