We're doing something convoluted ;-)
We're forcing a script (needs to run on other unix platforms) to run during ssh key authentication via the ssh option 'command=' which is attached to a public key in authorized_keys2.
The purpose of the command= option is to force a command to a particular key and to exit .. But we want to use this command to record whose public key is being used to login to the userid. If a command (SSH_ORIGINAL_COMMAND) was passed along with the ssh command, then the command is read, evaluated then the script exits. But, if SSH_ORIGINAL_COMMAND was not passed, then we want the person to login normally. Now with BASH, we can use the '-l' parm to simulate a login shell. /sbin/sh does not have this capability. Does anyone know how I can start /bin/sh so that /etc/profile /home/~HOME/.profile gets executed?
This is for the root userid, so /sbin/sh is required
This is part of the code .. Obviously, the HP-UX piece isn't working ;-)
if [ "${SSH_ORIGINAL_COMMAND}" ]
then
logger $myProg: ${1} from ${SSH_CLIENT%% *} ran COMMAND: "${SSH_ORIGINAL_COMMAND%% *}" as $LOGNAME using ssh
eval ${SSH_ORIGINAL_COMMAND}
else
logger $myProg: ${1} from ${SSH_CLIENT%% *} logged in as $LOGNAME using ssh
cat /etc/motd
echo "${1} from ${SSH_CLIENT%% *} is loggin in as $LOGNAME"
if [[ $myOS = "HP-UX" ]]; then
. ./.profile
. ./.kshrc
exec /sbin/sh
elif [[ $myOS = "Linux" ]]; then
exec /bin/bash -l
else
exec /usr/bin/bash -l
fi
Thanks for any pointers
Richard