Linux使用者管理案例(第二版)

來源:互聯網
上載者:User

標籤:linux   使用者管理   限制使用者   密碼破解   john   

大量新增使用者

1、按照/etc/passwd檔案格式編寫使用者資訊檔users.info

xiaofang01::1001:503::/home/xiaofang01:/bin/bash #注意不能有空行,不然會報錯

 

2、newusers < users.info#newusers命令 匯入使用者資訊檔

 

 

3、pwunconv#取消shadow password功能

 

4、以[使用者名稱:密碼]的格式編寫密碼檔案passwd.info

 

 

5、chpasswd < passwd.info#匯入密碼檔案

 

6、pwconv#將密碼寫入shadow檔案 

【用指令碼編程的方式其實更加高效】

 


限制普通使用者su為root

1、groupadd sugroup

2、chmod 4550 /bin/su//將其他人的許可權全部清除

3、chgrp sugroup /bin/su//將su的所屬組改變為sugroup

此時:ls -l /bin/su 

 

4、usermod -G sugroup test//將使用者test加入到sugroup組

 



用sudo代替su: 

-在執行sudo命令時,臨時成為root 

-不會泄漏root口令 

-僅向使用者提供有限的命令使用許可權 

 

設定檔:/etc/sudoers[編輯配置該檔案命令的visudo],用vi直接修改設定檔/etc/sudoers不會生效

 

/etc/sudoers檔案格式

使用者名稱[%組名] 主機名稱[或ip地址]=命令[要用絕對路徑]

 

案例-授權普通使用者可以添加/刪除使用者[useradd/userdel]

1、visudo

2、xiaofang hadoop=/usr/sbin/useradd,/usr/sbin/userdel

 

   [切換到該使用者]

3、sudo /usr/sbin/useradd test#執行useradd命令[加sudo,加絕對路徑]


4、輸入密碼#xiaofang的密碼,而不是root的密碼

 

5、sudo -l#查看目前使用者所被授權的只有root才可執行檔命令

 

 

說明:

1、sudo可以使普通使用者以root身份執行命令,而不是只是執行root才能執行的命令

2、編輯/etc/sudoers時,可以使命令精確化

如:guest hadoop=/sbin/shutdown -h now

只讓guest執行-h now選項,其他任何選項都不能執行

 


案例-授權一個普通使用者全權管理Apache

1、構思好該使用者應有的許可權:

(1)編輯Apache的設定檔

(2)使用Apache的啟動指令碼

(3)更新網頁等

2、實現功能1

法一、改變該檔案的所有者chown

法二、改變該檔案的所屬組,並將w許可權授予該組,然後該使用者加入該組[比較常用]

法三、visudo法

添加:使用者地址=/bin/vi /etc/httpd/conf/httpd.conf

 

3、實現功能2

使用者 主機名稱 =/etc/rc.d/init.d/http start,/etc/rc.d/init.d/http reload,/etc/rc.d/init.d/http fullstatus,/etc/rc.d/init.d/http configtest

 

4、功能實現3

即需要對/var/www/html目錄有寫入權限#改變該目錄的所有者/所屬組

 


檢測使用者密碼強度(破解使用者密碼)

1、安裝破解工具:John the ripper 

 http://www.openwall.com/john/ 

2、grep liming /etc/passwd > /test/liming.passwd #提取使用者資訊

3、grep liming /etc/shadow > /test/liming.shadow #提取使用者密碼的加密密文

 

4、/test/john-1.6.6/run/unshadow /test/liming.* > /test/liming.john#合并成一個檔案

 

5、/test/john-1.6.6/run/john /test/liming.john #破解該使用者密碼

6、/test/john-1.6.6/run/john /etc/shadow#破解所有使用者的密碼

 

Linux使用者管理案例(第二版)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.