天天看點

拒絕使用者登入:/bin/false和/usr/sbin/nologin

要拒絕系統使用者登入,可以将其shell設定為/usr/sbin/nologin或者/bin/false

1
# usermod -s | --shell /usr/sbin/nologin username
或者

1
# usermod -s | -shell /bin/false username
/bin/false

/bin/false什麼也不做隻是傳回一個錯誤狀态,然後立即退出。将使用者的shell設定為/bin/false,使用者會無法登入,并且不會有任何提示。

/usr/sbin/nologin

nologin會禮貌的向使用者顯示一條資訊,并拒絕使用者登入:

This account is currently not available.

有一些軟體,比如一些ftp伺服器軟體,對于本地非虛拟賬戶,隻有使用者有有效的shell才能使用ftp服務。這時候就可以使用nologin使使用者即不能登入系統,還能使用一些系統服務,比如ftp服務。/bin/false則不行,這是二者的重要差別之一。

/etc/nologin

如果存在/etc/nologin檔案,則系統隻允許root使用者登入,其他使用者全部被拒絕登入,并向他們顯示/etc/nologin檔案的内容。

鎖定使用者賬戶

鎖定使用者賬戶

1
# passwd -l | --lock username
#解鎖使用者賬戶

1
# passwd -u | --unlock username
删除使用者密碼

1
# passwd -d | --delete username
           

  

轉載于:https://www.cnblogs.com/heidsoft/p/7674606.html