[mythtv-users] Remotely monitor Backend is running

Stephen Worthington stephen_agent at jsw.gen.nz
Fri Oct 15 08:49:07 UTC 2021


On Thu, 14 Oct 2021 17:41:09 -0500, you wrote:

>
>Hi Bill!
>> The Count parameter just tells the GetUpcomingList endpoint how many upcoming
>> recordings to return. I selected 1 because I assume you really care that at
>> least one recording will be made in the future.
>>
>> Count=0 returns ALL upcoming recordings. That's OK, but probably more than
>> you need.
>>
>> If "Count" : "0", is returned , there are no upcoming recordings.
>>
>> If there curl fails, it's unable to communicate with the backend
>> or at least with the Services API thread.
>
>
>Thanks for the explanation – that helps so I can figure how to create a 
>“if see ‘0’ then display the error message” routine. ...I can’t find it 
>right now but the other day there was a post to me which did a reboot of 
>the Backend when it saw a problem. Seems like it needed to be told to 
>reboot the remote machine (Backend) as as it was seemed like it would 
>reboot the local machine.
>
>
>Barry

It is possible to control a remote machine via ssh.  First make sure
sshd is installed on the remote machine and enable root login:

sudo apt install sshd
cd /etc/ssh

Then edit sshd_config to enable root logins.  Add a line:

PermitRootLogin yes

That normally goes in the "Authentication" section.  Restart sshd to
enable the new setting:

sudo systemctl restart sshd

If the remote PC does not have a root password, install one:

sudo passwd

Then from the local machine login to root on the remote machine:

ssh root@<remote PC>

It will challenge you about the key being new if you have never used
that login before - answer yes.  Then give the root password for the
remote PC, and after it logs in, exit again.

Generate a key pair:

ssh-keygen

Copy the public key of the key pair to the remote PC:

ssh-copy-id -i root@<remote PC>

Use the exact same root@<remote PC> form that you are going to use to
login with on an ssh command.  If you use a host name, you will always
need to use the same format of host name (with or without the domain).
If you use an IPv4 address, you will always need to use that IP
address. If you use an IPv6 address, you will always need to use that
IPv6 address. You will be asked for the remote PC's password before it
will copy the key.

Now try logging in to the remote PC again:

ssh root@<remote PC>

That should work without the password.  At this point, you need to
decide whether you want to have the remote PC root account accessible
from anywhere on your network just using an ssh password login.  If
you do not want that, go to (or ssh to) the remote PC again and edit
/etc/sshd_config again.  Change the "PermitRootLogin" option from
"yes" to "prohibit-password" and restart sshd again, and run this
command:

sudo passwd -dl root

to delete the root password and lock the root account (password login
not permitted). Now root logins will only be allowed using a key pair
(or via sudo, as usual).  An ssh key pair connection is very secure,
but having a key pair set up does mean that the remote PC is now only
as secure as the local user on this PC.

So now in a script on the local PC running as your normal user, you
can do things like:

ssh root@<remote PC> <script-name>

to run a script on the remote PC as root.  The remote script could do:

systemctl restart mythtv-backend

for example, to restart mythbackend.  Or:

reboot

to reboot the remote PC.


More information about the mythtv-users mailing list