How to obfuscate a shell script?

前端 未结 4 1121
生来不讨喜
生来不讨喜 2020-12-20 07:26

I am using Ubuntu 10.04. i have created a shell script. After writing the script, the code can be edited when right clicking the file and selecting Gedit. I want to know how

4条回答
  •  北海茫月
    2020-12-20 08:20

    What you want to do is not readily possible. Scripts are interpreted, not compiled, that's why you see text in there.

    For an script to be executed, the effective user must have read access to it. An alternative to giving execution permission or using shc (as KillerX has nicely proposed), without letting the user look at the contests of the script, would be to use sudo. You would edit the sudoers file like this (remember to use visudo to edit this file!):

    username ALL=(ALL) /path/to/your_script.sh
    

    Now the script would be executable by "username" but he wouldn't be able to read its contents. Of course, you need to remove all permissions to "username" from this file...

提交回复
热议问题