开发者

linux command line, password protect file using script

really new to linux scripting so i figured i would ask rather than waste time pulling my hair out.

i have a simple script that backs up the contents of a folder on my linux box 开发者_开发百科and moves it to S3 storage, i would like this script to create a zip file and password protect it without any intervention from me.

i got it down to

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

but cannot work out where i should put the password to stop it prompting me.

thanks kris


Doing that is a security risk as it means your password will be written in cleartext in your script.

For this reason, zip refuses to work that way. It wants the input from the keyboard, not your script or a file.

I'm not aware of a workaround.

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


You could also use the security features provided by the file system. This is indeed another story, but it does protect your information in most cases.

So I guess doing a chown and chmod on your archive after creating it will prevent unwanted users from accessing the file, if all you need is a file that can only be read by a certain group. The main advantage is that there's no need to memorize a password here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜