As shown in the related question on serverfault , How do I edit the SSH “last login” message? , the line itself is built into the /usr/sbin/sshd
binary. Thus to edit it it would be necessary to edit source code and recompile it yourself, which is somewhat more of a bother and more work than necessary
Confirming the results found on serverfault question
DIR:/xieerqi
skolodya@ubuntu:$ file /usr/sbin/sshd
/usr/sbin/sshd: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=b0aaeed8d674586459d21eb2d548a848c33de3a9, stripped
DIR:/xieerqi
skolodya@ubuntu:$ strings /usr/sbin/sshd | grep -i "last login"
Last login: %s
Last login: %s from %s
You can however tell sshd
not to print message of the day and the last login (as per this answer )
Open the file /etc/ssh/sshd_config
with any editor, make sure if you use command line editor you use sudo
and if GUI editor - gksu
, for instance
sudo vi /etc/ssh/sshd_config
Append the following lines
PrintMotd no
PrintLastLog no
You can place the following function into your $HOME/.bashrc
file at the top
function ssh_login_date
{
if [ ! -z "$SSH_CLIENT" ]; then
printf "Last login %s from %s \n" "$( date +%F" "%H":"%M":"%S )" "$(echo $SSH_CLIENT| awk '{print $1}' )"
fi
}
And call the function at the end of the file
ssh_login_date