All links of one day
in a single page.
<Previous day - Next day>

rss_feedDaily RSS Feed
floral_left The Daily Shaarli floral_right
——————————— May 14, 2014 - Wednesday 14, May 2014 ———————————
ssh - audit -

Une astuce utile pour faire un audit des connexions par clé sur un compte (quand on a plusieurs personnes avec des clés différentes qui accèdent au meme user)

Implémentation rapide :

!/bin/bash

#On convertit le authorized_keys pour ajouter la variable d'env

cp ~/.ssh/authorized_keyz ~/.ssh/authorized_keyz.ORIGINAL

IFS=$'\n'
for line in $(cat .ssh/authorized_keys)
do
comment=$(echo $line|cut -d' ' -f3)
echo "environment=\"SSH_USER=$comment\" $line" >> ~/.ssh/authorized_keyz.COMMENT
done

cp ~/.ssh/authorized_keyz.COMMENT ~/.ssh/authorized_keyz

Puis dans le bashrc de l'user, ajouter ça :

if [ "$SSHUSER" != "" ]; then
now=$(date +%Y-%m-%d
%H-%M-%S)
echo $now : User $SSH_USER logged in >> ~/ssh-audit.log
fi

-