[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [OT] Remote SSH (dynamic IP) without third-party server



On Tue 11 Aug 2020 at 07:39:00 (-0400), Greg Wooledge wrote:
> On Mon, Aug 10, 2020 at 11:18:10PM -0500, David Wright wrote:
> > $ cat /etc/cron.daily/send-hotmail 
> > #!/bin/sh
> > [ -x /root/.cron/send-hotmail.sh ] || exit 0
> > /root/.cron/send-hotmail.sh
> > $ cat /root/.cron/send-hotmail.sh 
> > #!/bin/sh
> > mailx -s 'ZZZ---ZZZ' myfreeaccount@hotmail.co.uk < /etc/mailname
> > $ 
> 
> Why have two one-liner scripts?  Why not just put the mailx command
> in the send-hotmail script directly?

Personal policy. Many of my /etc configuration files are generated
from, as it were, templates under /root. For example, hosts is built
from a master list (≡router's DHCP) and an internet list of blocked
sites, fstab is built from a set of USB/SDcard/caddies plus a
host-specific section. Anything cron related, like apt-get update/
-d upgrade, and so on, lives under /root/.cron.

Lines that are in a cron table typically just call a separate script,
even when it's a single line, which allows the script to be edited
without rerunning crontab or disturbing the /etc files.

> > … sends my home's IP address each day to a location I can read from
> > anywhere.
> 
> Who populates the /etc/mailname file, and how?

The d-i, and then dpkg-reconfigure exim4-config. mailx comments on
a lack of message body, and I don't want cron sending a local email
on account of any error/warning. So—might as well send some file.
As I said, it could be any useful information as desired. I just
chose it for this example, and it has no special significance.

> Is the IP address actually in the /etc/mailname file, or are you
> parsing it out of the Received: headers and ignoring the body?

The latter, eg,
 Received: from hostname.corp (ipN-N-N-N.ISP.net [n.n.n.n]) by …

Most of the emails would probably never get opened, particularly in
these times of limited opportunities to travel, and I'd just delete
them. (I'm told that they'd expire in they remained unread for long
enough.) The subject line could be designed to make it easy to
filter them out from other emails being sent to the same address.

Cheers,
David.


Reply to: