PDA

View Full Version : Kickstart, adding users



bschuhma
17th August 2017, 10:27 PM
Hi all,

I'm having a hard time adding a user in my kickstart. I started with fedora-live-minimal.ks which tries to create the liveuser in %post. That doesn't work in F26. I couldn't log in with ANY user until I found the rootpw command, so I set that and can at least log in as root. However, I cannot even use the user directive in the main area. Here are some snippets:

lang en_US.UTF-8
keyboard us
timezone US/Eastern
auth --useshadow --enablemd5
selinux --enforcing
firewall --enabled --service=mdns
xconfig --startxonboot
part / --size 3072 --fstype ext4
services --disabled=network,sshd
rootpw <rootpw removed - this part works>

user --name=anotherliveuser --password=anotherliveuser


.
.%packages snipped for brevity
.


%post --nochroot --log=/root/kickstart_post.log --interpreter /bin/bash

# add fedora user with no passwd
echo "Adding live user"
action "Adding live user" /user/sbin/useradd \$USERADDARGS -c "Live System User" liveuser
/usr/bin/passwd -d liveuser > /dev/null
/user/sbin/useradd someuser
/usr/bin/passwd -d someuser > /dev/null
echo "Done adding live user"

%end


FWIW, no log in /root/kickstart_post.log is ever created. I've tried with/without --nochroot, too.

Any ideas?

Thanks,

Bret

donatom
18th August 2017, 03:23 AM
If you are using Livemedia-creator, get an up-to-date ks (flatten if necessary) and make sure you are following Lorax Livemedia Creator wiki to the letter. I have been using fedora-live-xfce.ks (flattened) and liveuser is automatically created in %post without a password.

Here is where the user w/o password is created:

# add fedora user with no passwd
action "Adding live user" useradd \$USERADDARGS -c "Live System User" liveuser
passwd -d liveuser > /dev/null
usermod -aG wheel liveuser > /dev/null


The user's home must also be created (in this case for xfce desktop):

mkdir -p /home/liveuser/.config/xfce4


Here is what I did (following Lorax's wiki) at the beginning of the kickstart file:

#version=DEVEL
# X Window System configuration information
xconfig --startxonboot
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted --lock locked
# Use network installation
url --mirrorlist=https://mirrors.fedoraproject.org/mirrorlist?repo=fedora-26&arch=x86_64
# System language
lang en_US.UTF-8
# Firewall configuration
firewall --enabled --service=mdns
# Shutdown after installation
shutdown
# Network information
network --bootproto=dhcp --device=link --activate
# System timezone
timezone US/Pacific
# System authorization information
auth --useshadow --passalgo=sha512
# SELinux configuration
selinux --disabled
#boot password
rootpw rootme
# System services
services --disabled="sshd" --enabled="NetworkManager,ModemManager"
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
#swap size
part swap --size=512
# Partition clearing information
clearpart --all
# Disk partitioning information
part / --fstype="ext4" --size=8194

flyingdutchman
18th August 2017, 01:32 PM
Note that initially Kickstart runs with a limited chroot environment. At the end, it reboots the machine and then you have a real environment. It is easier to create user accounts and configure things at that time.

bschuhma
18th August 2017, 02:28 PM
@Flyingdutchman - I don't follow you... do it after the reboot using what means? My end goal is to distribute the iso, have users boot from it, automatically log into a single user's account, right into an app that I'm writing.

Are you suggesting "after the reboot" and have the user create the directory and user? I need all that automated. Or are you saying "after the reboot" == "%post"?

Thanks,

Bret

---------- Post added at 09:28 AM ---------- Previous post was at 09:26 AM ----------

Thank you Donatom! I am (was) using livecd-creator, but I'll look into using livemedia-creator and see if it makes any difference. :-)

Regards,

Bret

antikythera
18th August 2017, 02:46 PM
the standard fedora kickstarts set a user which doesn't need a password as follows, that should be available when the created ISO boots:


# add liveuser user with no passwd
action "Adding live user" useradd \$USERADDARGS -c "Live System User" liveuser
passwd -d liveuser > /dev/null
usermod -aG wheel liveuser > /dev/null

by the way, for fedora 25 onwards, the program to use is livemedia-creator (https://forums.fedoraforum.org/showthread.php?t=315055). it's not without it's issues though as covered in the thread I link to.