How to Disable SSH Login Messages on Linux

When you connect to your Linux server via SSH, you might see various welcome messages and system information that clutter your terminal. This guide shows you how to clean up your SSH login experience by removing these messages.

What You’ll Remove

By following this guide, you’ll disable:

  • Last login timestamps
  • System information (kernel version, distribution details)
  • Message of the Day (MOTD)
  • Welcome banners

Step 1: Edit SSH Configuration

Open the SSH configuration file with your preferred text editor:

sudo nano /etc/ssh/sshd_config

Add or modify these lines in the file:

PrintLastLog no
PrintMotd no
Banner none

Step 2: Disable Message of the Day

The MOTD displays system information when you log in. To disable it:

# Clear the existing MOTD
sudo truncate -s 0 /etc/motd

# Disable MOTD scripts
sudo chmod -x /etc/update-motd.d/*

Step 3: Disable Last Login via PAM

If the „Last login“ message still appears, disable it through PAM (Pluggable Authentication Modules):

sudo nano /etc/pam.d/sshd

Find this line and comment it out by adding a # at the beginning:

# session    optional     pam_lastlog.so

Step 4: Restart SSH Service

Apply your changes by restarting the SSH service:

sudo systemctl restart sshd

Or on older systems:

sudo service ssh restart

Step 5: Test Your Changes

Log out and log back in to see your clean terminal. You should now see only your command prompt without any system messages.

Troubleshooting

Still seeing messages? Try these additional steps:

  1. Check if settings are applied: grep -i "PrintLastLog\|PrintMotd" /etc/ssh/sshd_config
  2. For Tailscale SSH users: The above methods should work, but if you’re still seeing messages, they might be coming from your shell profile.
  3. Verify SSH service restarted: sudo systemctl status sshd

Security Note

Disabling login messages doesn’t affect your server’s security. These messages are purely informational and removing them creates a cleaner login experience while maintaining all security features.

Reverting Changes

To restore the original login messages:

  1. Remove or comment out the lines you added in /etc/ssh/sshd_config
  2. Restore MOTD scripts: sudo chmod +x /etc/update-motd.d/*
  3. Uncomment the PAM lastlog line in /etc/pam.d/sshd
  4. Restart SSH: sudo systemctl restart sshd

Your SSH login will now be clean and minimal, showing only what you need to get to work.

 

Loading

Über chukfinley

I am a long time Linux user and FLOSS enthusiast. I use Debian with DWM. Furthermore, I know how to code in Python, Flutter, HTML (How to meet ladies). I also love minimalism.

Zeige alle Beiträge von chukfinley →

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert