# System-wide .bashrc file for interactive bash(1) shells.

# Lookup the COMMENT of the ssh-2 key used for authorization (if any)
fingerprint=`cat /var/log/syslog | sed -rn "s/^.*sshd\[$PPID\]: Found matching RSA key: ([0-9:a-f]+).*$/\1/p" | head -n1`
export fingerprint

fname="/tmp/sshkey-login$$.tmp"
grep "^ssh-rsa" /etc/ssh/root-authorized_keys 2> /dev/null | while read key ; do
   echo "$key" > $fname
   if [ `ssh-keygen -l -f $fname | cut -d ' ' -f2` = "$fingerprint" ] ; then
      logger -p security.info -t "LOGIN[$PPID] " "Accepted public key for: `cat $fname | cut -d ' ' -f3-`"
      break
   fi
done
rm -f $fname

# If running interactively, then:
if [ "$PS1" ]; then

    # set a fancy prompt (overwrite the one in /etc/profile)
#    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

    # check the window size after each command and, if necessary,
    # update the values of LINES and COLUMNS.
    shopt -s checkwinsize

    # enable bash completion in interactive shells
    #if [ -f /etc/bash_completion ]; then
    #    . /etc/bash_completion
    #fi
fi
