Sms-to-shell systemd implementation

I have the the sms-to-shell [GitHub - itiligent/SMS-to-Shell: Secure remote control & interactive linux shell access over SMS. (Supports TOTP auth for remote shell commands)] working running via Crontab.
I am trying now to implement as systemd as recommended by David the program author. (If you are out there David, I joined Github but couldn’t figure out how to reach out for help there, so I am back here)
I am hoping someone can provide a bit of clarity by confirming my interpretation of what is happening in
sms-to-shell-setup.sh and sms-to-shell.service
Also any guidance - directly or via useful reference - on how to work in the root space. I have tried sudo , sudo su and su and find it a very unfriendly workspace. Im the Boss of the computer and it really doesn’t feel that way.
I think systemd has some big benefits and I would like to get it going.
I do understand that the sms-to-shell-setup.sh is a neat way to put everything in place.

So does the systemd .service file actually will look like this once the variables are applied?


[Service]
ExecStart=/usr/bin/python3
/opt/sms-to-shell/sms-to-shell.py
(Paul: This is were the py script is put?)

WorkingDirectory=$INSTALL_DIR
(Paul:# Is this /opt/sms-to-shell/
the outer directory of where the py script is??

Restart=always

RestartSec=5

User=‘root’


Additionally -
Does the actual systemd .service file go here like this?
/lib/systemd/system/sms-to-shell.service


Some questions i have:
a) How do I change the py script if I need to, with permissions being really stubborn in that folder ( /opt/ ) Definitely can’t do anything via graphical interface. Do I make a new version of script and ‘sudo cp’ overwrite it??
OR
Can I put the py script in one of my user folders where I can easily work with it or is root space better?

b) Should I change
SHELL_USER=“root” # Commands will run in this user context.
to
SHELL_USER=“Paul”
?
Any guidance is much appreciated.
Paul

1 Like

To edit the script in /opt/, you need root privileges. You can use sudo with your editor, e.g.:

sudo nano /opt/sms-to-shell/sms-to-shell.py

2 Likes

You could create a new user with elevated privages. Thats what a pureist would do.

But if this isnt paid work for a contract or software for safety or secruity i think its reasonable to allow root to handle sms to shell protocol. Particuarly if the only person sending sms is you.

1 Like

Oh I think you might be looking for nano. Its a text editor in linux. Have a look at a few images of nano online and let me know if ive found the right thing for you.

1 Like

Hi lia,
Thanks. I am giving it a go sudo-ing my way around. using Sudo cp to put files in. Sudo rm to remove files. And Sudo nano to edit. thanks for your input. Best regards Paul

2 Likes

Hi Pixmusix
Thanks for your suggestions. making some small progress at the moment.
Appreciate your help
regards
Paul

1 Like