Skip to content

Instantly share code, notes, and snippets.

@jecxjo
Created April 22, 2021 19:17
Show Gist options
  • Save jecxjo/18bb25ca5daf295d4fb5805ac019abad to your computer and use it in GitHub Desktop.
Save jecxjo/18bb25ca5daf295d4fb5805ac019abad to your computer and use it in GitHub Desktop.
Self Contained Secure Shell Script
#!/usr/bin/env bash
#
# To use, encrypt a script with openssl cli and append the contents below the
# __ARCHIVE_BELOW__ line. The current example encrypted script takes two args.
# The password is "asdf".
#
# To encrypt:
# $ openssl aes-256-cbc -a -salt -in <script name> -out <enc name>
ARCHIVE=$(awk '/^__ARCHIVE_BELOW__/ {print NR + 1; exit 0;}' "$0")
tail -n+"$ARCHIVE" "$0" | openssl aes-256-cbc -d -a -salt 2>/dev/null | bash -s $@
exit 0
__ARCHIVE_BELOW__
U2FsdGVkX1+Ls1hWlt9yxlv9RP+GyzJBKOrUoLfYwh7Dq1FyEZ28qzOD5G65rmD1
UAuNerCGb6pSD1AX4t8V/vSY3+8sMVDwUx8fVP0HgYD+nXucqBLqv9PwExd/+4F0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment