調整 Linux 作業系統預設的帳號、密碼

在 Embedded Linux 中,作業系統一般都有預設的帳號、密碼,此帳號通常還具有 super user 權限,因此為了安全性考量,需要在客製化作業系統時,進行修改。

可以利用 adduser 指令來建立具有 super user 權限的帳號、密碼,並利用 deluser 指令移除預設的帳號。

 

 

預設帳號、密碼如何建立

以 Debian 作業系統為例,預設的帳密為 linaro/linaro,建立的方式是透過類似於在 0001-setup_user_linaro.chroot 的指令:

#!/bin/sh

echo "I: create linaro user"
adduser --gecos linaro --disabled-login linaro

echo "I: set linaro user password"
echo "linaro:linaro" | chpasswd

 

 

桌面系統如何指定登入的使用者名稱

指定登入的使用者名稱的設定檔為:
/etc/lightdm/lightdm.conf
相關的設定內容為:
    autologin-user=linaro

 

 

桌面系統如何自動登入

自動登入的設定檔為:
/etc/pam.d/lightdm-autologin
相關的設定內容為:
       auth      required pam_succeed_if.so user != root quiet_success
       auth      required pam_permit.so

經測試,移除 "auth    required pam_permit.so" 該行後,即無法自動登入桌面。

 

 

對作業系統帳號、密碼進行調整

在客製化作業系統時,利用 adduser 指令來建立具有 super user 權限的帳號、密碼,並利用 deluser 指令移除預設的帳號。

新增使用者,並設定 login shell 為 /bin/bash:
  - # adduser --system --group --gecos user_k --disabled-login user_k --shell /bin/bash
      --system
              Create a system user or group.
      --group
              When combined with --system, a group with the same name and ID as the system user is created.
       --gecos GECOS
              Set the gecos field for the new entry generated.
       --disabled-login
              Do not run passwd to set the password.  The user won't be able to use her account until the password is set.
       --shell SHELL
              Use SHELL as the user's login shell, rather than the default specified by the configuration file.

設定使用者密碼:
  - # echo "user_k:user_k" | chpasswd
增加 super user 權限到使用者:
  - # adduser user_k sudo

 

 

 

Reference

How to Create Users in Linux (useradd Command)

 

 

文字內容 或 影像內容 部份參考、引用自網路,如有侵權,請告知。

 

arrow
arrow
    全站熱搜

    silverwind1982 發表在 痞客邦 留言(0) 人氣()