六月丁香五月婷婷,丁香五月婷婷网,欧美激情网站,日本护士xxxx,禁止18岁天天操夜夜操,18岁禁止1000免费,国产福利无码一区色费

學(xué)習(xí)啦 > 學(xué)習(xí)電腦 > 操作系統(tǒng) > Linux教程 > Linux系統(tǒng)中怎么限制用戶(hù)su-權(quán)限

Linux系統(tǒng)中怎么限制用戶(hù)su-權(quán)限

時(shí)間: 孫勝龍652 分享

Linux系統(tǒng)中怎么限制用戶(hù)su-權(quán)限

  Linux下su-命令主要用于完整的切換到一個(gè)用戶(hù)環(huán)境,而該命令通常所有用戶(hù)都能使用,那么如果要限制一般用戶(hù)使用,該如何做呢?下面學(xué)習(xí)啦小編就給大家介紹下Linux中限制用戶(hù)su-權(quán)限的方法。

  但是,為了更進(jìn)一步加強(qiáng)系統(tǒng)的安全性,有必要建立一個(gè)管理員的 組,只允許這個(gè)組的用戶(hù)來(lái)執(zhí)行“su -”命令登錄為root用戶(hù),而讓其他組的用戶(hù)即使執(zhí)行“su -”、輸入了正確的root密碼,也無(wú)法登錄為root用戶(hù)。在UNIX和Linux下,這個(gè)組的名稱(chēng)通常為“wheel”。

  一、禁止非whell組用戶(hù)切換到root

  1、 修改/etc/pam.d/su配置

  代碼如下:

  [root@db01 ~]# vi /etc/pam.d/su ← 打開(kāi)這個(gè)配置文件

  #auth required /lib/security/$ISA/pam_wheel.so use_uid ← 找到此行,去掉行首的“#”

  2、 修改/etc/login.defs文件

  代碼如下:

  [root@db01 ~]# echo “SU_WHEEL_ONLY yes” 》》 /etc/login.defs ← 添加語(yǔ)句到行末以上操作完成后,可以再建立一個(gè)新用戶(hù),然后用這個(gè)新建的用戶(hù)測(cè)試會(huì)發(fā)現(xiàn),沒(méi)有加入到wheel組的用戶(hù),執(zhí)行“su -”命令,即使輸入了正確的root密碼,也無(wú)法登錄為root用戶(hù)

  3、 添加一個(gè)用戶(hù)woo,測(cè)試是否可以切換到root

  代碼如下:

  [root@db01 ~]# useradd woo

  [root@db01 ~]# passwd woo

  Changing password for user woo.

  New UNIX password:

  BAD PASSWORD: it is WAY too short

  Retype new UNIX password:

  passwd: all authentication tokens updated successfull

  4、通過(guò)woo用戶(hù)登錄嘗試切換到root

  代碼如下:

  [woo@db01 ~]$ su - root ← 即使密碼輸入正確也無(wú)法切換

  Password:

  su: incorrect password

  [woo@db01 ~]$

  5: 把root用戶(hù)加入wheel組再?lài)L試切換,可以切換

  代碼如下:

  [root@db01 ~]# usermod -G wheel woo ← 將普通用戶(hù)woo加在管理員組wheel組中

  [root@db01 ~]# su - woo

  [woo@db01 ~]$ su - root ← 這時(shí)候我們看到是可以切換了

  Password:

  [root@db01 ~]#[code]《/p》 《p》  《strong》二、添加用戶(hù)到管理員,禁止普通用戶(hù)su到root《/strong》《/p》 《p》  6、添加用戶(hù),并加入管理員組,禁止普通用戶(hù)su到root,以配合之后安裝OpenSSH/OpenSSL提升遠(yuǎn)程管理安全《/p》 《p》[code]  [root@db01 ~]# useradd admin

  [root@db01 ~]# passwd admin

  Changing password for user admin.

  New UNIX password:

  BAD PASSWORD: it is too short

  Retype new UNIX password:

  passwd: all authentication tokens updated successfully.

  [root@db01 ~]# usermod -G wheel admin (usermod -G wheel admin 或 usermod -G10 admin(10是wheel組的ID號(hào)))

  [root@db01 ~]# su - admin

  [admin@db01 ~]$ su - root

  Password:

  [root@db01 ~]#

  方法一:wheel組也可指定為其它組,編輯/etc/pam.d/su添加如下兩行

  代碼如下:

  [root@db01 ~]# vi /etc/pam.d/su

  auth sufficient /lib/security/pam_rootok.so debug

  auth required /lib/security/pam_wheel.so group=wheel

  方法二:編輯/etc/pam.d/su將如下行#符號(hào)去掉

  代碼如下:

  [root@db01 ~]# vi /etc/pam.d/su

  #RedHat#auth required /lib/security/$ISA/pam_wheel.so use_uid   ← 找到此行,去掉行首的“#”

  #CentOS5#auth required pam_wheel.so use_uid   ← 找到此行,去掉行首的“#”

  #保存退出即可============

  代碼如下:

  [root@db01 ~]# echo “SU_WHEEL_ONLY yes” 》》 /etc/login.defs ← 添加語(yǔ)句到行末

  上面就是Linux中限制用戶(hù)su-權(quán)限的方法介紹了,建立一個(gè)wheel用戶(hù)組,就能防止非wheel的用戶(hù)使用su-命令了,你學(xué)會(huì)了嗎?

307894