Solaris 10 10/08 安裝指南:自訂 JumpStart 及進階安裝

使用結束程序檔設定系統的 Root 密碼

系統安裝 Solaris 軟體後會重新啟動。在啟動程序完成前,系統會提示您輸入 Root 密碼。除非鍵入密碼,否則系統無法完成啟動。

名為 set_root_pw 的結束程序檔會儲存在 auto_install_sample 目錄中。結束程序檔顯示如何在不進行提示的情況下,自動設定 Root 密碼。範例 4–6 中會顯示 set_root_pw


備註 –

如果您使用結束程序檔設定系統的 Root 密碼,使用者可能會嘗試從結束程序檔中的加密密碼來找出 Root 密碼。請確保您可以防止使用者嘗試確定 Root 密碼。



範例 4–6 使用結束程序檔設定系統的 Root 密碼

	 #!/bin/sh
	 #
	 #       @(#)set_root_pw 1.4 93/12/23 SMI
	 #
	 # This is an example Bourne shell script to be run after installation.
	 # It sets the system's root password to the entry defined in PASSWD.
	 # The encrypted password is obtained from an existing root password entry
	 # in /etc/shadow from an installed machine.
 
	 echo "setting password for root"
 
	 # set the root password
 PASSWD=dKO5IBkSF42lw
	 #create a temporary input file
 cp /a/etc/shadow /a/etc/shadow.orig
 
	 mv /a/etc/shadow /a/etc/shadow.orig
 	nawk -F: '{
         if ( $1 == "root" )
           printf"%s:%s:%s:%s:%s:%s:%s:%s:%s\n",$1,passwd,$3,$4,$5,$6,$7,$8,$9
      else
		        printf"%s:%s:%s:%s:%s:%s:%s:%s:%s\n",$1,$2,$3,$4,$5,$6,$7,$8,$9
      }' passwd="$PASSWD" /a/etc/shadow.orig > /a/etc/shadow
 #remove the temporary file
 rm -f /a/etc/shadow.orig
 # set the flag so sysidroot won't prompt for the root password
 sed -e 's/0 # root/1 # root/' ${SI_SYS_STATE} > /tmp/state.$$
  mv /tmp/state.$$ ${SI_SYS_STATE}

下面將描述此範例中的一些指令。