解压缩脚本密码

时间:2012-07-09 06:11:14

标签: passwords zip archive

好的,这是我的剧本

    #!/bin/bash
cd /var/backups/System/
unzip Themes.zip
exit 0

我需要脚本在解压缩受保护的zip文件(即Themes.zip)时自动输入密码。由于用户不知道密码,因此在解压缩zip存档时需要通过脚本输入密码。希望这可以做到吗?

2 个答案:

答案 0 :(得分:8)

使用-P标志密码。来自man unzip

-P password
              use  password to decrypt encrypted zipfile entries (if any).  THIS IS INSECURE!  Many multi-user operating systems provide ways for any user to see the current command line of any other user; even on stand-alone systems there is always the threat of over-the-shoulder peeking.  Storing the plaintext password as
              part of a command line in an automated script is even worse.  Whenever possible, use the non-echoing, interactive prompt to enter passwords.  (And where security is truly important, use strong encryption such as Pretty Good Privacy instead of the relatively weak encryption provided by standard  zipfile  utili-
              ties.)

答案 1 :(得分:2)

  

解压缩-P密码Themes.zip

退出0