How to force sshd server to display login banner before login (change the ssh server login banner)

Pre login banner is use for sending a warning message before authentication may be relevant for getting legal protection or just give out information to users. The contents of the specified file are sent to the remote user before authentication is allowed. This option is only available for protocol version 2. By default, no banner is displayed (if you are using latest version of Linux/UNIX then you do not have to worry about version issue).

Procedure to change OpenSSH pre login banner

1) By default sshd server turns off this feature.

2) Login as the root user; create your login banner file:

# vi /etc/ssh/sshd-banner

Append text:
Welcome to nixCraft Remote Login!

3) Open sshd configuration file /etc/sshd/sshd_config using a text editor:

# vi /etc/sshd/sshd_config

4) Add/edit the following line:

Banner /etc/ssh/sshd-banner

5) Save file and restart the sshd server:

# /etc/init.d/sshd restart

6) Test your new banner (from Linux or UNIX workstation or use any other ssh client):

$ ssh vivek@rh3es.nixcraft.org

Output:
Welcome to nixCraft Labs!
vivek@ rh3es.nixcraft.org’s password:

Please note that this feature may not work with third party ssh client such as Putty.

🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
23 comments… add one
  • Premnath Bangar Sep 2, 2015 @ 5:17

    I have one queries about SSH Banner. How can I put ssh banner in Linux. I have know about /etc/issue, /etc/motd and make changes in /etc/ssh/sshd_config file.

    But question is that I have more than 100 Linux server It’s too much time consuming to make entry in each server. So, is there another way to do banner in SSH. Like, I can put banner file in one server and all the other server can use same file for the banner.

  • dood Aug 8, 2015 @ 21:22

    Mine says: “Fuck china, and fuck you!”
    Lets see if that rally up the 90% of scum bag “hackers”.

  • John Jan 18, 2015 @ 17:07

    That’s all fine and dandy but unless you patch openssh you can telnet port 22 and get a very descriptive banner – that’s the one i’d be interested in deactivating.

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.