With iOS 12 and the new Siri Shortcuts app, I've been thinking of ways I could leverage the SSH command capability in the app. For those of you who don't know, the app allows you to send a bash file or string to stdin
and returns stdout
as a plain-text file, connecting using password authentication (no token authentication).
What I'd like to do is create a shortcut that executes sudo shutdown [...]
on a remote server via the SSH command action. Since the action is non-interactive and non-tty I can't interactively enter the password, and I'm reluctant to put the password as plaintext in the action input string/stdin
. On the other hand, I don't want to use sudo -n
and NOPASSWD
for the shutdown
command, as that's a security risk that I don't want to deal with. I thought of perhaps requiring a random string for the shutdown
message for NOPASSWD
to be enabled in the sudoers
file (i.e., sudo shutdown -h now
would require a password, but sudo shutdown -h now japos98vh92p3hoab982hfpa
would not), but I don't know if that's any more secure or even possible.
In summary, how can I securely send a shutdown command over SSH using a non-interactive, non-tty session?
NOPASSWD
is "a security risk that I don't want to deal with". Like, it sounds like you've set your security bar, then realized that your client can't meet it, and are stuck trying to make them fit together. – Mike Ounsworth Sep 19 '18 at 21:50sudo shutdown -h now japos98vh92p3hoab982hfpa
meets your security requirements depends on what your security requirements are. The usual security model ofsudo
requires a hands-on-keyboard admin to type the password. Are you willing to weaken this to "anybody with your phone"? Or "Anybody who can see your Siri history"? Or "Anybody who can see your bash history?". Only you can decide what you consider "secure". – Mike Ounsworth Sep 19 '18 at 21:57