Wiki‎ > ‎

Encrypt shell script

posted Apr 26, 2017, 12:19 PM by Dong Xu   [ updated Apr 26, 2017, 12:56 PM ]
Alternative: https://unix.stackexchange.com/questions/90178/how-can-i-either-encrypt-or-render-my-shell-script-unreadable

  1. Write your script (script-base.sh)

    #!/bin/sh 
    echo "Hello World" 
  2. Encrypt your script (give a password):

    openssl enc -e -aes-256-cbc -a -in script-base.sh > script-enc 
  3. Write de Wrapper (script-final.sh):

    #!/bin/sh 
    openssl enc -d -aes-256-cbc -a -in script-enc | sh - 
  4. Run "script-final.sh", enter the password, and the script will run without write the plain text script on disk.

Comments