centos7 添加用戶並受權root權限

2019-03-28centos


 

centos7.2 版本,咱們不可能每次都用root帳號登錄,root帳號公認的不安全,因此,首先,禁止掉root帳號的登錄。
1.靜止root帳號登錄安全

$ vi /etc/ssh/sshd.conf (ssh服務的配置文件,直接修改)
----------------------------------
PermitRootLogin no ( 找到這一行,並將其改成 no )
---------------------------------------
保存退出
$ systemctl restart sshd (重啓一下sshd服務)

2.建立用戶並受權ssh

$ adduser sss (建立用戶sss)
$passwd sss (建立sss的密碼)
$ chmod -v u+w /etc/sudoers   (增長 sudoers 文件的寫的權限,默認爲只讀)
$ vi /etc/sudoers (修改 sudoers)
-------------------------------------------------------
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
sss    ALL=(ALL)       ALL (添加這一行)
-------------------------------------------------------

保存,退出post

 

$ chmod -v u-w /etc/sudoers (刪除 sudoers 的寫的權限)

 

好了,如今帳號已經建立好了,使用sss帳號登錄後,在命令前加 sudo 則是使用root權限了。第一次使用會彈出一些提示信息,正常現象。centos7

--------------------- 
轉載:https://blog.csdn.net/weixin_41004350/article/details/78491798 
spa

相關文章
相關標籤/搜索