Configuring SSH Login and Changing Login Messages in Ubuntu

Secure Shell (SSH) is a widely used protocol for remote login to systems, providing encrypted communication between clients and servers. In this troubleshooting guide, we will walk you through the process of configuring SSH login settings and changing login messages in Ubuntu, a popular Linux distribution. We’ll cover the steps in a step-by-step manner, ensuring that you can successfully customize your SSH login experience.

Opening the SSH Configuration File:
Open a terminal or SSH into the Ubuntu server and enter the following command to open the SSH configuration file in a text editor:

sudo nano /etc/ssh/sshd_config

Modifying SSH Login Settings:
Locate the relevant settings in the configuration file and make the necessary modifications. For example:

  • To disable the “Last login” message, find the line containing PrintLastLog and set it to no.
  • To customize the welcome message, find the line containing Banner and specify the path to the desired banner file.

Save the changes by pressing Ctrl + X, then Y to confirm, and Enter to save the file.

Restarting the SSH Service:
To apply the configuration changes, restart the SSH service with the appropriate command:

  • Ubuntu/Debian: sudo service ssh restart
  • CentOS/Fedora/Red Hat: sudo systemctl restart sshd
  • macOS: sudo launchctl stop com.openssh.sshd followed by sudo launchctl start com.openssh.sshd
  1. Changing Login Messages:
    Now let’s explore how to change login messages, including removing the “Last login” message and modifying the welcome message.

Modifying the MOTD (Message of the Day) File:
The MOTD file displays a message to users upon login. To modify it, follow these steps:

sudo nano /etc/motd

Remove or modify the existing content in the file as desired. Save the changes and exit the text editor.

Removing the “Last login” Message:
To remove the “Last login” message displayed after login, modify the SSH configuration file as discussed in Step 2.2. Set PrintLastLog to no and restart the SSH service.

Modifying the Welcome Message:
To customize the welcome message displayed after login, you can create a banner file. Follow these steps:

sudo nano /etc/ssh/banner

Enter the desired welcome message in the file. Save

the changes and exit the text editor.

Open the SSH configuration file (sudo nano /etc/ssh/sshd_config) and locate the Banner line. Set the path to the banner file you created (e.g., /etc/ssh/banner).

Save the changes to the SSH configuration file and restart the SSH service.

Modifying System-wide Configuration:
If the message appears to be the same for all users, it is possible that it is being generated from a system-wide configuration file. To locate and modify the source of the message, follow these steps:

  • Open a terminal or SSH into the Ubuntu server with administrative privileges.
  • Look for system-wide shell configuration files such as /etc/profile, /etc/bash.bashrc, or files in the /etc/profile.d/ directory.
  • Open the file using a text editor (e.g., sudo nano /etc/profile).
  • Search for the lines or commands that generate the undesired message.
  • Comment out or remove the lines that generate the message by adding a # character at the beginning of the line.
  • Save the changes and exit the text editor.

By examining and modifying the system-wide configuration files, you should be able to locate and modify the source of the message that appears the same for all users during SSH login.


In this troubleshooting guide, we have covered the steps to configure SSH login settings and change login messages in Ubuntu. By following these steps, you can customize your SSH login experience, including removing the “Last login” message and modifying the welcome message. Remember to make necessary backups and exercise caution when modifying system files.

SSH configuration provides a high degree of flexibility, allowing you to tailor the login experience according to your needs.