<div dir="ltr">One option is to keep the username and password in /etc/rhn/spacewalk.creds or something, which only the user running your script has access to, and the file has very restrictive permissions on.  In there, you can specify your username and password and then source it from your script.<div><br></div><div>It would be even better if Spacewalk implemented some sort of access token that could be granted to a system, registered System ID, or something, but I don't know if that is in the works.</div><div><br></div><div>For the first idea:</div><div><br></div><div>file /etc/rhn/spacewalk.creds:</div><div><br></div><div>SPACEWALK_USER=admin</div><div>SPACEWALK_PASS=12345</div><div>export SPACEWALK_USER</div><div>export SPACEWALK_PASS</div><div><br></div><div>in your script:</div><div>CREDFILE=/etc/rhn/spacewalk.creds </div><div>if [ -f "${CREDFILE}" ]; </div><div>  . "${CREDFILE}"</div><div>fi</div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Sep 8, 2017 at 7:53 AM Michael Mraka <<a href="mailto:michael.mraka@redhat.com">michael.mraka@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Sreenivasa Katra:<br>
> Hi Michael,<br>
><br>
> I am running a shell script in which it downloads all the channels  along<br>
>  with the errata for my centos 7 spacewalk server.<br>
> In the script for authentication, i need to hard-code<br>
>  SPACEWALK_USER=admin,  and SPACEWALK_PASS=abcdef<br>
><br>
> Instead of hard coding is there any way to encrypt this in shell script.<br>
><br>
> Please provide your inputs.<br>
<br>
Well, the thing is if your script have to use login/password it have to<br>
be able to decrypt it. But then anyone having access to the script can<br>
see how it decrypts password and do the same. So if you have plaintext<br>
or encrypted password in the script - it's equaly bad.<br>
Encrypting password in such case is just a classic example of alleged security<br>
(through obscurdity).<br>
<br>
--<br>
Michael Mráka<br>
System Management Engineering, Red Hat<br>
<br>
_______________________________________________<br>
Spacewalk-list mailing list<br>
<a href="mailto:Spacewalk-list@redhat.com" target="_blank">Spacewalk-list@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/spacewalk-list" rel="noreferrer" target="_blank">https://www.redhat.com/mailman/listinfo/spacewalk-list</a><br>
</blockquote></div>