Customized ssh login message

Submitted by aknnn on Sat, 09/29/2018 - 17:59

Sometimes you may wan't to display customized welcome message when logging in to server via ssh.

I'm going to show you how you can do it with CentOS 7.

First open the file /etc/ssh/sshd_config and add this line to it:
PrintMotd no
This will disable the default message printed on login and let's you print your own.

Next you wan't to make your own customized message. This is done by creating a file in the folder named /etc/profile.d
It doesn't matter how you name the file, altought the extension must be .sh
I named mine login_message.sh

First line of this file must be:
#!/bin/bash

In the next line you can add an echo-command and a string to be printed on login:
echo "Welcome to your server"

Save the file and make it executable:
chmod +x login_message.sh

The last thing to do is restart your sshd service:
systemctl restart sshd

Next time you login to your ssh, the newly created message should be shown.

Comments

Add new comment