#!/bin/bash # # Copyright 2006, CRIM, Revolution Linux Inc. # # $Id: 20_sendsshkeys.sh 1559 2006-03-28 21:03:46Z arsenaiv $ # # Authors : Gabriel Lefebvre <Email> # # This file is part of the MILLE-XTERM project. # # http://www.revolutionlinux.com/mille-xterm/ # http://www.mille.ca/ # # This program is covered by the GNU General Public License. # See the COPYING file in the top-level MILLE-XTERM directory. # # ------------------------------------------------------------------------- # # Pre session script used in MILLE-XTERM project # To be copied in the /etc/X11/gdm/PreSession directory # # This script should be called by /etc/X11/gdm/PreSession/Default with the following line : # /etc/X11/gdm/PreSession/sendsshkeys.sh & # SSH=/usr/bin/ssh SCP=/usr/bin/scp IPADDR=`echo $DISPLAY | cut -f1 -d":"` if [ -z $IP ]; then IP="localhost" fi WRKDIR=${HOME}/.localapps SETUPSSHKEYS=/usr/sbin/setupsshkeys.sh SSHPORT=`grep "^Port " /etc/ssh/sshd_config|cut -f2 -d" "` if [ -z $SSHPORT ]; then SSHPORT=22 fi # # Launch setupsshkeys command on the terminal # PUBKEY=`cat /tmp/${USER}-key.pub` PRIVKEY="/tmp/${USER}-key" DISPLAY="" $SSH root@$IPADDR "$SETUPSSHKEYS $PUBKEY" & mysendkeys() { SERVER=`hostname -i` rm -f /tmp/$USER.ent /tmp/$USER.grp >/dev/null 2>&1 getent passwd $USER > /tmp/$USER.ent getent group $USER > /tmp/$USER.grp $SCP $XAUTHORITY root@$IPADDR:/tmp/.Xauthority $SCP $PRIVKEY root@$IPADDR:/tmp/$USER-key $SCP /tmp/$USER.ent /tmp/$USER.grp root@$IPADDR:/tmp/ c1="cat /tmp/$USER.ent >> /etc/passwd; cat /tmp/$USER.grp >>/etc/group" c2="chown $USER /tmp/$USER-key" c3="killall sshfs" c4="mkdir -p $HOME" c5="sshfs -o nonempty -o allow_other -p $SSHPORT $USER@$SERVER: " c6="$HOME -o IdentityFile=/tmp/$USER-key" c7="rm -f /tmp/$USER-key" c8="chown $USER /dev/audi* /dev/mix* /dev/dsp* /dev/mid* /dev/snd/*" cmd="$c1;$c2;$c3;$c4;$c5 $c6;$c7;$c8" $SSH root@$IPADDR "$cmd" rm $PRIVKEY rm $PRIVKEY.pub } (echo 10; mysendkeys; echo "100") \ | zenity --progress --pulsate --auto-close \ --progress-text "Sending SSH keys to the terminal" \ --title "Please wait..." --width 320