[Spacewalk-list] Encrypting admin username and password of spacewalk server

Sreenivasa Katra sreenivasa.k at jdmsoftwareindia.com
Fri Sep 8 07:32:16 UTC 2017


Hi Michael,

I am running a shell script in which it downloads all the channels  along
 with the errata for my centos 7 spacewalk server.
In the script for authentication, i need to hard-code
 SPACEWALK_USER=admin,  and SPACEWALK_PASS=abcdef

Instead of hard coding is there any way to encrypt this in shell script.

Please provide your inputs.

Here is the shell script

#!/bin/sh
MAILTO=root

# try to create the lock and check the outcome
LOCKFILE=/var/run/spacewalk_sync.lock
if [ -e "$LOCKFILE" ]; then
 echo "Another instance already running. Aborting."
 exit 1
else
 touch "$LOCKFILE"
fi
trap "rm ${LOCKFILE}" EXIT

#sync channels and publish updates

/usr/bin/spacewalk-repo-sync -c mm_centos7  >/dev/null
/usr/bin/spacewalk-repo-sync -c centos7-updates >/dev/null



#get errata file and checksums
cd /tmp
wget -N http://cefs.steve-meier.de/errata.latest.xml 1>/dev/null 2>&1
wget -N http://cefs.steve-meier.de/errata.latest.md5 1>/dev/null 2>&1
wget -N http://www.redhat.com/security/data/oval/com.redhat.rhsa-all.xml.bz2
1>/dev/null 2>&1
bunzip2 -f /tmp/com.redhat.rhsa-all.xml.bz2

#verify integrity

grep "errata.latest.xml$" errata.latest.md5 > myerrata.md5
md5sum -c myerrata.md5 1>/dev/null 2>&1

if [ "$?" == 0 ]; then
 #ok - import errata

 SPACEWALK_PASS=abcdef  SPACEWALK_USER=admin /opt/tools/errata-import.pl
--server 192.168.24.48 --errata errata.latest.xml
--include-channels=mm_centos7,centos7-updates
--rhsa-oval=/tmp/com.redhat.rhsa-all.xml --publish 1>/dev/null

 if [ "$?" != 0 ]; then
 echo "It seems like there was a problem while publishing the most recent
errata..."
 exit 1
 fi

 rm /tmp/myerrata.md5
else
 #errata information possibly invalid
 echo "ERROR: md5 checksum mismatch, check download!"
 exit 1
fi


Thanks
Sreenivasa


On Fri, Sep 8, 2017 at 12:27 PM, Michael Mraka <michael.mraka at redhat.com>
wrote:

> Sreenivasa Katra:
> > Hello,
> >
> > How do i encrypt "admin" username and "password" of spacewalk server in
> > shell script?.
>
> Hello,
>
> what do you want to achieve? Why do you want to encrypt it?
>
>
> --
> Michael Mráka
> System Management Engineering, Red Hat
>
> _______________________________________________
> Spacewalk-list mailing list
> Spacewalk-list at redhat.com
> https://www.redhat.com/mailman/listinfo/spacewalk-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/spacewalk-list/attachments/20170908/b9b341a1/attachment.htm>


More information about the Spacewalk-list mailing list