Linux password protect file with script

really new to linux scripts, so I decided that I would ask and not waste time pulling my hair.

I have a simple script that maintains the contents of a folder in my linux window and moves it to the S3 repository, I would like this script to create a zip file and password protect it without any intervention with me.

i got it before

zip myarchive.zip /var/www/* -e 

but cannot decide where I should put the password in order to stop it, so that it prompts me.

thanks Kris

+4
source share
2 answers

Doing this is a security risk, as it means that your password will be written in text form in your script.

For this reason, zip refuses to work this way. He wants to enter from the keyboard, not your script or file.

I don't know about a workaround.

On the other hand, at least zip in my Ubuntu distribution offers the -P password option, which I think allows you to enter the password directly on the command line. Documentation surrounds this parameter with appropriate warnings.

+6
source

You can also use the security features provided by the file system. This is really a different story, but in most cases it protects your information.

Therefore, I assume that after creating the chown and chmod file in your archive, attempts to access unwanted users to the file will be prevented if you only need a file that can only be read by a specific group. The main advantage is that there is no need to remember a password.

0
source

Source: https://habr.com/ru/post/1315951/


All Articles