Skip to main content
edited body
Source Link
noisy
  • 131
  • 6

enter image description hereenter image description here

enter image description here

enter image description here

Source Link
noisy
  • 131
  • 6

In addition to @F. Hauri answer, I prepare useful "LoggedIn prompt".

One additional file is optional ($HOME/.ssh/users):

kszumny@laptop kszumny kszumny@comp2 kszumny tom@laptop tom pati@home chris@workstation1 chris chris@workstation2 chris 

This part should be pasted to /etc/profile (for all users) or to ~/.bashrc

other_users_prompt() { pids=`ps fx | grep "sshd:\s" | awk '{print $1}'` users="" for uid in $pids do ssh_crtFp=`sed -ne "/sshd.$uid.:.*matching .SA key/{s/^.* //g;p;q}" /var/log/sshdusers.log` for ((ssh_i=1;ssh_i<=$(wc -l <$HOME/.ssh/authorized_keys);ssh_i++));do export ssh_line="$(sed -ne ${ssh_i}p <$HOME/.ssh/authorized_keys)" echo "$ssh_line" >tempKey export ssh_lFp=($(ssh-keygen -l -f tempKey)) if [ "${ssh_lFp[1]}" == "$ssh_crtFp" ] ;then export SSH_KEY_USER=${ssh_line##* } ST_USER=`cat $HOME/.ssh/users | grep "${SSH_KEY_USER}" | awk '{print $2}'` if [ -z "$ST_USER" ]; then ST_USER=$SSH_KEY_USER fi if [ -z "$users" ]; then users="$ST_USER" else users="$users\n$ST_USER" fi break fi done done if [ `echo -e "$users" | sort | uniq -c | wc -l` == 1 ]; then exit fi users=`echo -e "$users" | sort | uniq -c | awk '{print $2"("$1")"}' | xargs echo -e` echo -e "[LoggedIn:$users] " } PS1='$(other_users_prompt)\u@\h:\w\$ ' 

Result

enter image description here