Solaris 10 5/09 安装指南:自定义 JumpStart 和高级安装

使用结束脚本设置系统的超级用户口令

Solaris 软件安装到系统上之后,系统会重新引导。在引导过程完成前,系统提示输入超级用户口令。除非有人键入口令,否则系统无法完成引导。

名为 set_root_pw 的结束脚本保存在 auto_install_sample 目录中。结束脚本显示如何自动设置超级用户口令,而无需提示。示例 4–6 中显示了 set_root_pw


注 –

如果使用结束脚本设置系统的超级用户口令,则用户可以尝试从结束脚本的加密口令中搜索超级用户口令。确保有相应的措施防止用户试图确定超级用户口令。



示例 4–6 使用结束脚本设置系统的超级用户口令

	 #!/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}

以下说明此例中的一些命令。