From 0a6b9e73afbb37960391733ea960d24fdf84aad1 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Wed, 25 Jan 2017 15:13:06 +0100 Subject: [PATCH] fixed dd + random sats password generation --- clone/clone | 12 ++++++++++- clone/tmp/shadow | 42 +++++++++++++++++++++++++++++++++++++ clone/utility/service_unit | 3 +-- clone/utility/shadow_append | 2 +- 4 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 clone/tmp/shadow diff --git a/clone/clone b/clone/clone index 23489c4..cb267c3 100755 --- a/clone/clone +++ b/clone/clone @@ -88,7 +88,7 @@ step3(){ test $confirm_burn != "y" && echo "<<< aborting" && exit; # (2) Burning image into disk # - ( dd if=./original.img bs=4M | pv -s $(du -bs ./original.img | awk '{print $1}') | sudo dd of=$DEV bs=4M ) \ + ( dd if=./original.img | pv -s $(du -bs ./original.img | awk '{print $1}') | sudo dd of=$DEV bs=4M ) \ || $( echo "<<< error: dd command failed" && exit ); echo "<<< done"; @@ -131,6 +131,16 @@ step5(){ echo " (.) Adding 'sats' user and updated 'pi'"; echo " > /etc/shadow"; cat ./utility/shadow_append | tee -a ./tmp/shadow > /dev/null; + + # (3) Setting sats random password # + echo " (.) Set sats random password" + RANDOM_PASS=$(tr -dc A-Za-z0-9_ < /dev/urandom | head -c 150); + RANDOM_SHADOW="$(python3 -c "import crypt; print(crypt.crypt(\"${RANDOM_PASS}\", crypt.mksalt(crypt.METHOD_SHA512)))")"; + RANDOM_SHADOW="$(echo $RANDOM_SHADOW | sed 's/\//\\\//g')" + cat ./tmp/shadow | sed -e "s/sats-passowrd/$RANDOM_SHADOW/"; + + + cat ./tmp/shadow | sudo tee /mnt/etc/shadow | sudo tee /mnt/etc/shadow- > /dev/null; rm ./tmp/shadow; diff --git a/clone/tmp/shadow b/clone/tmp/shadow new file mode 100644 index 0000000..6566238 --- /dev/null +++ b/clone/tmp/shadow @@ -0,0 +1,42 @@ +root:$6$ndI3Yluj$IsyVa2pH9C9uaaDwXpuAo4CCoKed3MZ2wh.9riQjkRzRmNZL11tEqRnQWaTucpYz29423JBLm8QG740geSm/9/:17186:0:99999:7::: +daemon:*:16911:0:99999:7::: +bin:*:16911:0:99999:7::: +sys:*:16911:0:99999:7::: +sync:*:16911:0:99999:7::: +games:*:16911:0:99999:7::: +man:*:16911:0:99999:7::: +lp:*:16911:0:99999:7::: +mail:*:16911:0:99999:7::: +news:*:16911:0:99999:7::: +uucp:*:16911:0:99999:7::: +proxy:*:16911:0:99999:7::: +www-data:*:16911:0:99999:7::: +backup:*:16911:0:99999:7::: +list:*:16911:0:99999:7::: +irc:*:16911:0:99999:7::: +gnats:*:16911:0:99999:7::: +nobody:*:16911:0:99999:7::: +systemd-timesync:*:16911:0:99999:7::: +systemd-network:*:16911:0:99999:7::: +systemd-resolve:*:16911:0:99999:7::: +systemd-bus-proxy:*:16911:0:99999:7::: +syslog:*:16911:0:99999:7::: +_apt:*:16911:0:99999:7::: +messagebus:*:16911:0:99999:7::: +uuidd:*:16911:0:99999:7::: +lightdm:*:16911:0:99999:7::: +whoopsie:*:16911:0:99999:7::: +avahi-autoipd:*:16911:0:99999:7::: +avahi:*:16911:0:99999:7::: +dnsmasq:*:16911:0:99999:7::: +colord:*:16911:0:99999:7::: +speech-dispatcher:!:16911:0:99999:7::: +hplip:*:16911:0:99999:7::: +kernoops:*:16911:0:99999:7::: +pulse:*:16911:0:99999:7::: +rtkit:*:16911:0:99999:7::: +saned:*:16911:0:99999:7::: +usbmux:*:16911:0:99999:7::: +xdrm-brackets:$6$aA2bAv6a$jaInJx6rStN5X9pz7fMv4RTJL8XJzLhc6ajywifQbM5mM0TQu4hH0bQq/bzmD27rQAHkMdxJoZBQGMly6wpz//:17185:0:99999:7::: +mysql:!:17185:0:99999:7::: +test:$6$2w5LdwSD$KZP5f6maw3x0vKNhSj97KXhQLnm00iYSkjkYuk.TJK1YC.LssTHBWb03s5/1BZhXMhTzLb6xzox8EJ3kSyK4a1:17188:0:99999:7::: diff --git a/clone/utility/service_unit b/clone/utility/service_unit index 19042e5..c236263 100644 --- a/clone/utility/service_unit +++ b/clone/utility/service_unit @@ -1,9 +1,8 @@ [Unit] Description=SATS (Secure Authentication and Tracking SYSTEM) Daemon -After=multi-user.target [Service] -Type=Simple +Type=simple User=sats ExecStart=/bin/sh /home/sats/satsd/boot service 2>> /home/sats/satsd/log/boot.log >> /home/sats/satsd/log/boot.log Restart=on-abort diff --git a/clone/utility/shadow_append b/clone/utility/shadow_append index 92b3855..b18e443 100644 --- a/clone/utility/shadow_append +++ b/clone/utility/shadow_append @@ -1,3 +1,3 @@ pi:$6$k0vFWRoG$bEBdFcFBWw2fLEA.5LsVKOtLWdWSkZMnEikqOG4jHCneRrWEBnEt6.ROe60ggdA7DbdU.l2ZO35WFvi3q6Ays/:17130:0:99999:7::: -sats:$6$k0ddNARW$TDcFuts/WK62gt5QIlFCqN.4MSwj4Q3SsJZ6tUvcbjZXjt2TsiVdkkv9PgO/0yR.on8.Aj2/.WHHU28GXwdo51:17185:0:999999:7:: +sats:sats-password:17185:0:999999:7::