I need to run a script as a regular user on a remote machine whose root I do not trust. This script outputs very sensitive data to stdout.

What steps can I take to ensure only I can read the script’s output?

What steps can I take to ensure remnant files on the disk (if there are any) are permanently destroyed?

  • 3
    short answer you can't – Kiwy Jun 6 '18 at 12:22

Root has all privileges on the machine, so there's no way you can protect stdout from root.

If the data had only to transit through the machine (e.g. via a network interface) a solution would be to encrypt it at the source, but since the data is generated on the same machine the root user can easily modify the script to fetch the unencrypted data.

As a rule, if you don't trust a machine, don't run anything on it.

Also, there's a contradiction in the sentence "This script outputs very sensitive data to stdout" -- if it's very sensitive data, you shouldn't dump it to stdout, unless you are the only user on the machine.

  • 3
    Moreover, if the script produces sensitive data, root can use auditd mechanisms to see any command ran on the server, and play it as any user to get the data. So yes : if you don't trust, don't put sensitive data on it... – tonioc Jun 6 '18 at 12:28

With ssh you can run the script on a remote system and forward it's output to your local secure machine:

ssh regularuser@inesecure.host "/path/to/the/script/on/remotehost.sh" > /file/on/your/local/system.txt
  • The OP said "I need to run a script as a regular user on a remote machine". I imagine if he/she can just run the script on a different machine all the problems would be solved. – dr01 Jun 6 '18 at 11:56
  • 2
    Using the command above, OP can run the script located on the remote host and forward the output to the local system. – Mikhail Zakharov Jun 6 '18 at 12:06
  • What would stop the root user to run again the script and fetch the results locally? – dr01 Jun 6 '18 at 12:56
  • @dr01 secure delete/shred the script when done – ivanivan Jun 6 '18 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.