“Easy” remote-admin — static systemd service

In the previous two posts we dealt with the script ‘after.local’, which is a remnant on openSUSE of the ‘init’-days, before systemd became the standard.

After looking more closely, it turns out that there is a ‘unit-file’ for ‘after.local’ backward-compatibility. This makes the following rather simple.

Essentially we’ll just have to copy/rename/paste a few files to create a new service that does what we want ;-)

We’ll end up with a ‘rescue_ssh.sh’ script in ‘/usr/local/bin’, a ‘rescue_ssh.service’ unit-file for systemd + a symlink to that in the ‘multi-user.target.wants’ folder. On openSUSE the relevant systemd unit files etc. live in ‘/usr/lib/systemd/system/…’.

Download here.

A few notes:

* The file ‘$HOME/.mailrc’ must be owned and readable by the user (600).
* The file ‘/usr/local/bin/rescue_ssh.sh’ must be executable (root.root + 600).
* It is vital that the rescue_ssh service is started AFTER any firewall.

This post is an extension to the previous one, so I suggest reading that as well.

This entry was posted in Computer / Server and tagged , . Bookmark the permalink.