Why does a plaintext password with rootpw parameter of Kickstart doesn't interpret password containing # (hash) character?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 6
  • Kickstart

Issue

  • The kickstart file contains the root password with # character and it's in plain text as follows.
rootpw redhat#1
  • The resulting machine sets root password to only redhat, it skips everything beyond # character, why?

Resolution

  • This has been fixed with an Errata as well.
  • Use rootpw line as follows.
rootpw "test#1
  • As a workaround for previous to Red Hat Enterprise Linux 6.9, write a %post script to reset the password.
%post
echo redhat#1 | passwd --stdin root
%end

Root Cause

  • Anaconda doesn't seem to take anything beyond # if the password contains that.
  • This happens because # is considered as a starting of a comment and comments are not interpreted by anaconda.
  • In general, # marks the beginning of a comment in a kickstart file. Comments can either be the whole line, if # comes at the beginning, or from some point to the end of the line. That's what's happening here - pykickstart is reading everything from the # right as a comment and tossing it out.

Diagnostic Steps

  • Install Red Hat Enterprise Linux 6.7 using the following kickstart file.
[root@kickstart ~]# cat /var/ftp/kickstart_hash.cfg
install
text
cdrom
lang en_US
keyboard us
network --bootproto dhcp onboot=yes
zerombr
bootloader --location mbr
timezone America/Denver
auth --enablemd5 --enableshadow
selinux --disabled
rootpw redhat#1
firewall --disabled
skipx
clearpart --all --initlabel 
reboot

part /boot --fstype=ext3 --size=200 
part pv.01 --size=1000 --grow 
part swap --size=1000  --fstype=swap
volgroup myvg pv.01 
logvol /home --vgname=myvg --name=homevol --size=500
logvol / --vgname=myvg --name=rootvol --size=1000 --grow
%packages 
@base
-kexec-tools
-NetworkManager
  • Once installation is done, try login with root user and password both redhat and redhat#1

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments