Skip to content

How-to

Allow commands on a host ​

This guide lets chosen commands run on a server without a question, and keeps everything else asking. It assumes a key and a trusted host (Run your first command).

A rule for ssh_exec names a user, a host and a command:

text
admin@web.home.example systemctl status *

A * word matches any one word; as the last word, any number of words, or none.

From an approval ​

When a chat asks Run a command on web.home.example as admin?, choose Always. Beneath it:

ChoiceAllowsExample for systemctl status nginx
This targetthis exact commandadmin@web.home.example systemctl status nginx
Widerthe command's first words, with any arguments after themadmin@web.home.example systemctl status *

The wider choice keeps all but the last word, at most two: docker ps -a becomes docker ps *, uptime -p becomes uptime *. The sheet shows one wider choice; the same command on the parent domain (*.home.example) is another the daemon knows. A command that starts a runner, such as sh -c, python3 or sudo, keeps its exact words: no answer turns it into every command.

In the app ​

  1. Open Permissions and tap ssh_exec.

  2. Tap Add a command and type one rule per line:

    text
    admin@web.home.example systemctl status *
    admin@*.home.example uptime
  3. Under Gets, choose Chat (or an agent) and allow.

From the terminal ​

sh
nocturn perms set chat ssh_exec 'admin@web.home.example systemctl status *' allow --reload
nocturn perms set agent:backup ssh_exec 'admin@nas.home.example restic *' allow --reload

Patterns ​

PartSyntax
usera login, or *; optional
hostweb.home.example, *.home.example (the domain and its subdomains), or *
port:2222, only when it is not 22
commandwords; a * word is any one word, a last * any number; * and ? inside a word do not cross /

A rule with no command is refused: write <host> * if you really mean every command. A bare * allows everything for that holder; the app marks it as a blank cheque.

nocturn is open source. Example hosts and people on these pages are made up.