SSH Banners

From banana_wiki
Revision as of 15:31, 10 April 2014 by Bananafish (talk | contribs) (Created page with "''Various ways to display messages before logging in and after logging in with SSH. Good to be funny or displaying a security message.'' ''Change pre-login message for local ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Various ways to display messages before logging in and after logging in with SSH. Good to be funny or displaying a security message.

Change pre-login message for local shell login:

nano /etc/issue
Welcome to derp derp server
Today is \d \t @ \n

/etc/issue - escape code

The issue-file (/etc/issue or the file set with the -f option) may contain certain escape codes to display the system name, date and time etc. All escape codes consist of a backslash () immediately followed by one of the letters explained below.

\b : Insert the baudrate of the current line.
\d : Insert the current date.
\s : Insert the system name, the name of the operating system.
\l : Insert the name of the current tty line.
\m : Insert the architecture identifier of the machine, eg. i486
\n : Insert the nodename of the machine, also known as the hostname.
\o : Insert the domainname of the machine.
\r : Insert the release number of the OS, eg. 1.1.9.
\t : Insert the current time.
\u : Insert the number of current users logged in.
\U : Insert the string "1 user" or " users" where is the number of current users logged in.
\v : Insert the version of the OS, eg. the build-date etc. </code>

Change pre-login message for ssh login:*

nano /etc/ssh/sshd-banner
Append text:
Welcome to derp derp ssh login!

Tell the sshd to dispaly the banner nano /etc/sshd/sshd_config </code>

Add the following line: Banner /etc/ssh/sshd-banner

Now restart the sshd for it to take affect: /etc/init.d/sshd restart

Change MOTD - after ssh login message: Message is stored in /etc/motd

nano /etc/motd

Script updates to the motd

mkdir /etc/update-motd.d
cat > /etc/update-motd.d/10uname <<EOF
#! /bin/sh
uname -snrvm
EOF
cat > /etc/update-motd.d/20tail <<EOF
#! /bin/sh
[ ! -f /etc/motd.tail ] && exit 0
cat /etc/motd.tail
EOF
chmod a+x /etc/update-motd.d/*

Source:
1 2 3 4