Automagically reboot Mikrotik router from OSMC

Posted on Thu 05 April 2018 in Automatyczny dom

Personas: MikroTik home router with Internet connection and WiFi LAN Raspberry Pi with OSMC media center OS (based on Kodi)
Login to OMSC
Generate key without password:
  1. 2ssh-keygen -t dsa
Transfer public key to Mikrotik router.
  1. 2scp ~/.ssh/ osmc@
Login to MikroTik router:
Add special group for remote users:
/user group add name="remote_ssh" policy=ssh,reboot,!local,!telnet,!ftp,!read,!write,!policy,!test,!winbox,!password,!web,!sniff,!sensitive,!api,!romon,!dude skin=default
Add new user into „remote_ssh� group:
/user add name=osmc group=remote_ssh password=****** comment='osmc user'
Import public key for „osmc� user:
/user ssh-keys import user: osmc
Login back into OMSC:
ssh osmc@
Create shell script called "�:
cat << EOF >
press <Enter> and paste following text:
  1. 2#!/bin/sh
  2. 4# script reboots Mikrotik home router
  3. 6xbmc-send -a "Notification(MikroTik,Rebooting router...)"
  4. 8ssh -l osmc -i ~/.ssh/id_dsa "/system reboot"
press <Enter>, write „EOF� (without quotes) and press <Enter> again. You will find „� file in current directory.
Make this script executable:
  1. 2chmod +x
You can now logout from OSMC ssh session. Following steps we will perform using OSMC GUI with keyboard or remote.
I couldn’t find a way to run my script from GUI in OSMC default skin. Also couldn’t find it in Confluence skin so I decided to install Aeon Nox skin which has such feature built in.
Installing Aeon Nox is easy:
In OSMC GUI go to:
chooseInstall from repository(v15/v16) /Get add-ons(v14)
selectKodi add-on repository
chooseLook and feel(v16 and higher)
selectAeon Nox
and finallyInstall
Now go back toSettings->Appearance->
fromSkinsubmenu selectAeon Noxand confirmYes.
New skin should be loaded now.
Now you can add new item on the Start Screen that will allow you to reboot your router.
Disclaimer: this will only work if network connection between your OSMC and your router is still working but only WAN (Internet) connection is down.
FromStart Screengo toSystem->Skin
fromHome WindowselectSetup the Aeon Nox main menu.
In left column selectCUSTOM1and in the right column selectDefault select action:
In the following window select Custom Item and in keyboard input write:
  1. 2System.Exec(/home/osmc/
and press <Enter>.
Go to Edit label and name it Reboot Router.
Be sure that option Enabled is turned on.
Go back to Start Screen and you should find new Reboot Router option. Select it and you sould see notification and after few second your MikroTik should restart.
Inform all members of your family about this item.
Usefull links:
Execute commands with SSH on MikroTik:

Full list of Kodi commands: