Here is a quick way to enable a person to perform a specific task on a server without providing them with a login. With SOX requirements becoming stricter you cannot allow just anyone to obtain access to the server.
This script was created to allow Tech personnel to test a local CUPS printer without providing them complete access to the server. On the server you want to add the user or generic account to the server. However, instead of providing them with a shell “-s /bin/bash” you provide them with the name of the script, “-s /usr/local/bin/zebra_test_env.ksh.”
Here is the script that makes this work:
#!/bin/ksh #Shell to test zebra printers with the techs login #Define the Variables AWK='/bin/awk' LP='/usr/bin/lp -d ' TESTJOB="/usr/local/bin/zebra_exampl.txt" LOOPOUT="exit" PING='/bin/ping' GREP='/bin/grep' echo "nEnter the name of the Zebra Label Printer you want tested:n" read X grep $X /etc/printcap ERR=$? if [[ $ERR -gt 0 ]] then echo "Printer $X Not Found in Printcapn" exit fi ping -c 3 $X ERR=$? if [[ $ERR -gt 0 ]] if [[ $ERR -gt 0 ]] then echo "Printer needs to be turned on or connected to the network n" exit fi while [[ $LOOPOUT != "Next" ]] do case $X in $X) echo "Printer $X is on the network, sending test page...n" lp -d $X /usr/local/bin/zebra_exampl.txt LOOPOUT="Next" ;; *) echo "nEnter the name of the Zebra Label Printer you want teste d or exit to logout:n" read X ;; esac done
In order to prevent a security breech you want the script to exit whenever the incorrect information is provided. Hope this helps in obtaining SOX compliance. You can modify the script to fit your needs.