How to Customize SSH Welcome Messages on Your Dedicated Server
Customizing your SSH welcome messages can be a great way to display important information, alerts, or system messages when users log into your dedicated server via SSH. This guide will walk you through the process of configuring and customizing these messages.
Step 1: Log into Your Server via SSH
- Use an SSH client like PuTTY (for Windows) or the terminal (for macOS/Linux) to connect to your dedicated server.
- Enter your server’s IP address and login credentials:
ssh username@your_server_ip
Step 2: Access the SSH Configuration Files
- The welcome message is generally displayed from the
motd
(Message of the Day) file or theissue
file. - Depending on your operating system, these files can be located in different directories:
- Ubuntu/Debian:
/etc/motd
,/etc/issue
,/etc/issue.net
- CentOS/RHEL:
/etc/motd
,/etc/issue
- Ubuntu/Debian:
Use the following commands to edit these files:
- For Ubuntu/Debian:
sudo nano /etc/motd sudo nano /etc/issue
- For CentOS/RHEL:
sudo nano /etc/motd sudo nano /etc/issue
Step 3: Customize the Message of the Day (MOTD)
- The MOTD is displayed immediately after the user logs into the server via SSH. This file is often used for displaying system information, alerts, or any other custom message you wish.
- You can add a simple welcome message, server information, or even a warning message for users. For example:
Welcome to Your Dedicated Server Server IP: your_server_ip Last login: $(last -i | head -n 1)
- You can also use
uname -r
to show the kernel version oruptime
for system uptime:System Information: Kernel: $(uname -r) Uptime: $(uptime -p)
Step 4: Customize the SSH Login Banner
- In addition to the MOTD, the
/etc/issue
file controls the pre-login banner that appears before authentication is complete. - You can add important information like system status, terms of use, or server-specific details. For example:
--------------------------------------------------------- Warning: Unauthorized access is prohibited. Please contact your system administrator for help. ---------------------------------------------------------
Step 5: Enable Dynamic MOTD (Optional)
- On Ubuntu and Debian, the MOTD can be dynamically generated using scripts located in the
/etc/update-motd.d/
directory. These scripts can pull system data like disk usage, server status, and more.
To enable dynamic MOTD, check the files in the /etc/update-motd.d/
directory:
ls /etc/update-motd.d/
Each script in this folder is executed when a user logs in, and the output is displayed in the MOTD. You can customize these scripts or create new ones to pull specific system data.
To add custom scripts, create a new script in /etc/update-motd.d/
:
sudo nano /etc/update-motd.d/99-custom
Make your modifications, save the file, and ensure it’s executable:
sudo chmod +x /etc/update-motd.d/99-custom
Step 6: Test Your Changes
- After saving your changes to the MOTD or SSH login files, test them by logging out and logging back in via SSH.
- You should now see the customized messages on login.
Step 7: Troubleshooting (If Needed)
- If you don’t see the customized messages, ensure that your system is using the correct configuration files.
- Double-check that the
motd
file is not being overwritten by other scripts or configuration settings, such as/etc/default/motd-news
on Ubuntu or other system-specific configuration files. - Ensure that the
/etc/issue
and/etc/motd
files have the correct permissions:sudo chmod 644 /etc/motd /etc/issue
Step 8: Additional Tips for Customizing SSH Messages
-
Include System Health Information: Display vital server stats such as CPU load, memory usage, or disk space to give users an overview of the server’s health. Example:
CPU Load: $(top -bn1 | grep "load average:" | sed "s/.*, *\([0-9.]*\),.*/\1/") Disk Space: $(df -h / | awk 'NR==2 {print $4}')
-
Add Login Time or Uptime: Include a countdown or server uptime to keep users informed about system performance. Example:
Uptime: $(uptime -p)
-
Security Alerts: Display alerts for server updates, maintenance schedules, or security tips. Example:
Attention: Ensure all software is updated to the latest version for security.
By following these steps, you can easily customize the SSH welcome messages on your dedicated server to provide a personalized experience for your users, display important system information, or reinforce security policies. Whether you want to show login details, warnings, or custom server stats, these changes will make the login process more informative.