Ssh – how to use different SSH banner for various SSH connections

sshd

Regarding /etc/ssh/sshd_config having specified within Banner /etc/issue

Since the SSH banner does not get presented until after entering the value for SSH login,

Is it possible to have a different (unique) banner presented based on the username entered for the SSH login?

Or is it possible to use specific banners based on the connecting IP address?

Is either of those somehow possible with the SSH version used in RHEL/CentOS 7.8 ?

Best Answer

well, if you mean show a different banner either per user or IP address connecting through ssh, you have options for these both as following using Match command;

  1. different banner based on username:

    # put in Match section like
    Match User sshUser
        Banner /path/to/specific_banner
    
  2. different banner based on IP address:

    # put in Match section like
    Match Address 10.20.30.0/24
        Banner /path/to/specific_banner
    

so, it's possible; you will just need to reload the sshd to take changes effect; if your sshd version has no reload command (in worst condition), you will need restart it.

Related Question