No hint "You have new mail"

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
Barney
Posts: 14
Joined: Sat Aug 01, 2020 10:39 pm

Re: No hint "You have new mail"

Post by Barney »

Joulinar wrote: Fri Feb 19, 2021 5:57 pm you can switch to OpenSSH Server as well using dietpi-software
Yes, I can, but that doesn't solve my problem with No hint "You have new mail"

Nevertheless, thanks for your reply.

For now I shall continue my configuration of the ZeroPi with plain vanilla armbian.
User avatar
MichaIng
Site Admin
Posts: 3032
Joined: Sat Nov 18, 2017 6:21 pm

Re: No hint "You have new mail"

Post by MichaIng »

Neither OpenSSH, nor Dropbear show /etc/issue(.net) by default:
- https://manpages.debian.org/buster/open ... tml#Banner
- https://manpages.debian.org/buster/drop ... ml#OPTIONS

The default configs provided by Debian (which we do not touch in this regards) do not change this. I guess it is seen as information leak which must be disabled until the admin manually changes it.

In case of Dropbear: /etc/default/dropbear contain the DROPBEAR_BANNER option which allows to define a banner file.
In case of OpenSSH: /etc/ssh/sshd_config has the Banner option to do so.



/etc/motd on OpenSSH is controlled by the PrintMotd option in /etc/ssh/sshd_config, which defaults to "yes": https://manpages.debian.org/buster/open ... rintMotd_2
But this option is overwritten by the official Debian openssh-server package's /etc/ssh/sshd_config to PrintMotd no, and hence on DietPi since we do not touch this setting.

In case of Dropbear, /etc/motd is printed by default, unless the -m option is passed or it is disabled at compile time. Even without printing the DietPi banner, I cannot see /etc/motd, even that neither the "-m" flag is passed, nor can I find a compile time option in the Debian build logs that would actively disable it. But I found an interesting upstream changelog: https://github.com/mkj/dropbear/blob/master/CHANGES#L81
That is from 2020.79, hence newer than what Debian Buster ships. Tested on Debian Bullseye, and voila:

Code: Select all

Using username "root".
Authenticating with public key "Micha-20200711"

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
 ─────────────────────────────────────────────────────
 DietPi v7.0.-1 (dev) : 16:11 - Tue 02/23/21
 ─────────────────────────────────────────────────────
 - FQDN/hostname : VM-Bullseye
 - LAN IP : 192.168.1.23 (eth0)
 - Freespace (RootFS) : 6.9G
 - MOTD : Please help testing DietPi beta v7.0.0:
          https://github.com/MichaIng/DietPi/issues/4121
 ─────────────────────────────────────────────────────

 DietPi Team     : MichaIng (lead), Daniel Knight (founder), Joulinar (support)
 Image           : DietPi Core Team (pre-image: Debian mini.iso)
 Web             : https://dietpi.com | https://twitter.com/DietPi_
 Patreon Legends : Camry2731
 Donate          : https://dietpi.com/#donate
 DietPi Hosting  : Powered by https://myvirtualserver.com

2021-02-23 16:11:25 root@VM-Bullseye:~#
Since there is no option to explicitly enable /etc/motd on Dropbear, if it is required, OpenSSH would need to be used on Debian Buster, and the default configuration file adjusted as mentioned above.



That the /etc/motd and likely the mail hints are printed before the DietPi banner, and hence moved into scrollback buffer, is indeed an issue. Three solutions I can think of:

1. Integrating those into the DietPi banner, which means that we would need to maintain a set of possible bash/shell prints.
2. Integrating the DietPi banner into /etc/motd, which means that we need to dynamically update that file.
3. Do not move the current screen content into the scrollback buffer when printing the DietPi banner, which means that the screen after login still contains the /etc/issue(.net) (when enabled on SSH server), login prompt + input, /etc/motd (when not disabled on SSH server) and then the DietPi banner. This would be the easiest solution, but it's probably user-preference. We could make it an option in the dietpi-banner menu :?.

@Barney
If you still run the DietPi system, it would be great to know whether the assumption is right that the mail hint is indeed printed before the DietPi banner, and hence can be seen when scolling up after SSH login, similar like the SSH login prompt + /etc/motd output in my paste above.
Barney
Posts: 14
Joined: Sat Aug 01, 2020 10:39 pm

Re: No hint "You have new mail"

Post by Barney »

MichaIng wrote: Tue Feb 23, 2021 4:22 pm @Barney
If you still run the DietPi system, it would be great to know whether the assumption is right that the mail hint is indeed printed before the DietPi banner, and hence can be seen when scolling up after SSH login, similar like the SSH login prompt + /etc/motd output in my paste above.
Your assumption is false. The mail hint is not printed before the DietPi banner.

This is the output of the DietPi login (the DietPi banner is disabled):

Code: Select all

ssh dpi
Weitere User im System:
dgs      pts/0        Feb 23 16:06 (10.91.25.13)
dgs      pts/1        Feb 23 16:06 (10.91.25.13)
dgs      pts/2        Feb 23 16:07 (10.91.25.13)
dgs      pts/4        Feb 23 18:51 (10.91.25.13)
root     pts/3        Feb 23 16:09 (10.91.25.13)
This is the output of the Armbian login:

Code: Select all

ssh azp
 _____              ____  _ 
|__  /___ _ __ ___ |  _ \(_)
  / // _ \ '__/ _ \| |_) | |
 / /|  __/ | | (_) |  __/| |
/____\___|_|  \___/|_|   |_|
                            
Welcome to Armbian 21.02.2 Buster with Linux 5.10.16-sunxi

System load:   2%           	Up time:       4 days 23:41		Local users:   4            	
Memory usage:  20% of 491M   	IP:            10.91.25.33
CPU temp:      34°C           	Usage of /:    17% of 5.0G   	

[ General system configuration (beta): armbian-config ]

You have new mail.
Last login: Tue Feb 23 15:57:06 2021 from 10.91.25.13
Weitere User im System:
dgs      pts/1        2021-02-23 15:55 (10.91.25.13)
dgs      pts/2        2021-02-23 15:55 (10.91.25.13)
dgs      pts/3        2021-02-23 15:57 (10.91.25.13)
dgs      pts/4        2021-02-23 18:58 (10.91.25.13)
root     pts/0        2021-02-23 12:59 (10.91.25.13)
With Armbian there is the mail hint and the 'last login' message. Both don't appear with DietPi.
User avatar
MichaIng
Site Admin
Posts: 3032
Joined: Sat Nov 18, 2017 6:21 pm

Re: No hint "You have new mail"

Post by MichaIng »

The "last login" message is not from the shell but from OpenSSH and as such it shows up very well on DietPi when switching to OpenSSH.

Btw, if you're expecting mails from failing cron jobs, note that for system cron jobs in /etc/cron.hourly/daily/... we disabled mails by default since most users will only see "(CRON) info (No MTA installed, discarding output)" in their syslog. Use dietpi-cron or sed -i '/MAILTO/d' /etc/crontab to enable it.

I enabled cron mails, created a minutely failing dummy cron job and installed sendmail. The two variables are now set automatically, nothing to do manually. /var/mail/root gets the cron job failure messages, but I still couldn't see the new mails message on SSH login. Then I switched to OpenSSH, and got a new mails message right after the install has finished:

Code: Select all

 DietPi-Software
─────────────────────────────────────────────────────
 Mode: Installation completed

[ SUB1 ] DietPi-Services > restart
[  OK  ] DietPi-Services | restart : cron
[ INFO ] DietPi-Software | Starting installed services, not controlled by DietPi-Services
[  OK  ] DietPi-Software | systemctl start ssh
You have new mail in /var/mail
and then as well on new SSH logins and on local console login, but the slightly shorter version "You have new mail.". Switched back to Dropbear, messages on SSH logins are gone, messages on local console stay, of course.

But while playing around, I see the mail messages on Dropbear as well, just not directly on login, instead when the first full minute has been reached, as part of the command prompt, when a cron job has failed and the MAILCHECK interval reached:

Code: Select all

2021-02-24 01:44:53 root@VM-Bullseye:~#
2021-02-24 01:44:57 root@VM-Bullseye:~#
You have new mail in /var/mail
2021-02-24 01:45:02 root@VM-Bullseye:~#
Okay I think I got it:
  • bash mail check works fine, but it does not print anything on login, but instead as part of the following command prompts, when new mails arrive AFTER login/the shell session started.
  • A direct notification about new mails on login seems to be a console/terminal feature, which is supported by OpenSSH and by login (local console), which explains why the text is different/shorter compared to the bash+OpenSSH one, but not by Dropbear.
So it's mostly about Dropbear vs OpenSSH here :).
Post Reply