I have a sequence of scripts which downloads PGP files from a FTP server. I then unzip these files with a private key using PGPKeys. The unzipped files are then picked up by a SQL Server job which appends the data onto our database. I'd like to automate the entire process. Is there anyway to unzip a PGP locked file using shell scripting (either Linux or Windows)?
That's a perfect task to automize, I can help you in Linux.
First you can use wget to download a file
wget ftp://website.com/yourpgparchive.zip
If your ftp website requires authenticated access use
wget --ftp-user=USER --ftp-password=PASSWORD ftp://ftp.site/archive.zip.pgp
Then you need gpg (the open source PGP implementation) to decrypt the file
gpg -o file.zip -d file.zip.gpg
(If you need some suggestion on how to import keys and get started with gpg check here)
Then you can just unzip the file with
unzip file.zip
You may need to install gnupg and unzip from your package manager.
Yes, GPG. In your case, it's just gpg -d filename (or just gpg -d to read from stdin).
And, what you probably wanted to say is decrypt instead of unzip and encrypted instead of locked.
Related
I had a requirement to compress a folder/directory and also encrypt it. And when needed i've to decrypt it. I did browse a lot to find a working answer on a MacOs. And i just manage to use the below steps to make it working.
Zip or tar zip the file/directory using zip or tar czf linux command
use "gpg --encrypt sample-file-or-folder.zip" Prompts you to enter the passphrase
Outcome of step 2, should result in sample-file-or-folder.zip.gpg
For decrypting .zip.gpg file use "gpg --output sample-file-or-folder.zip --decrypt sample-file-or-folder.zip.gpg" --> This prompts you to enter the passphrase. Please note that if you don't mention "--output" it will not get the desired output.
Is there any other better way to get the desired result ?
I use gpg for encrypting a file storing my passwords in Windows. This file is an MS Excel file, which I use for convenience. Every time I want to check or update my passwords (> once per day on average), I execute the following batch script, which decodes the encrypted file and encodes the updated xlsx file again when I close the application.
call gpg --output pass.xlsx --decrypt pass.xlsx.gpg
call "%ProgramFiles%\Microsoft Office\Office14\excel.exe" pass.xlsx
call gpg --batch --yes --recipient myName --encrypt pass.xlsx
del pass.xlsx
Obviously, this is a suboptimal solution as it creates a decrypted file, which in case of an interruption (e.g. accidentally closing the command line window or a system crash), the file remains unencrypted. Anyone with something better, e.g. using in-memory pipes or the like (in Windows)?
I need to create a shell script wherein I will unzip a password protected zip file. I know the password, and need to automate the unzip process.
How can I achieve this using Unix shell scripting?
unzip -P your-password zipfile.zip
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 utilities.)
In Ubuntu, I've to install 7zip (7z) archive tool using following command:
sudo apt-get install p7zip-full
Then, you can use Ubuntu's default Archive Manager to unzip the password protected zip files
I ran into problem using unzip saying need PK compat. v5.1 (can do v4.6).
Installed p7zip instead and unzipped using following command:
7z x archive.zip -ppassword
To unzip multiple password protected files, this command WILL NOT WORK
unzip -P PASSWORD *.zip
To make it work, you need to include the *.zip in quotes because whenever you use a wildcard (*), the shell itself will expand that and pass the results to the program. This is because, unlike most programs in UNIX, unzip cannot take more than one file at a time.
Read more here https://chrisjean.com/unzip-multiple-files-from-linux-command-line/.
Therefore, to unzip multiple protected files, use this
unzip -P PASSWORD '*.zip'
Please follow bellow instruction, i have solved same problem by following these steps.
sudo apt install p7zip-full
7z x example.zip
it will ask password for your zip file, provide password and let the process complete
Visit the following URL: For more details
I have a list of SWF files that I want to download to my PC. Is there a quick way to do this from my server, like using WGET or something similar. Each file line list is a new line:
http://super.xx-cdn.com/730_silvxxxen/v/v.swf
http://super.xx-cdn.com/730_sixxxxheen/73xxxxversheen.swf
http://super.xx-cdn.com/730_rxxxd/v/v.swf
There are thousands of lines.
If you use ssh over putty to access your server you could easily use winscp from putty
otherwise you could also use pscp
If you do not have putty installed get it and make up a ssh to your server
Another easy way to download them is just getting an FTP client and download them over FTP
You can use simple SH script, if I correctly understand your question:
#!/bin/sh
while IFS= read -r line
do
wget $line
done < "urls.txt"
I keep seeing this phrase "download or create" in tutorials right after tofrodos. What would be an example of how to download or create? I just get stuck in
^
^
^
mode.
apt-get -y install tofrodos
Download or create ZPX_ubuntu_12-04_auto_installer.sh
The author means you need to transfer the "ZPX_ubuntu_12-04_auto_installer.sh" shell script to the server, and if necessary, change to the directory you saved the script in using the cd command, before entering the commands below:
fromdos ZPX_ubuntu_12-04_auto_installer.sh
chmod +x ZPX_ubuntu_12-04_auto_installer.sh
./ZPX_ubuntu_12-04_auto_installer.sh
He seems to be referring to a particular script included in a .zip file posted on a web forum.
You may be able to download the .zip file to your computer, extract it, and then use the sftp or scp program to transfer just the shell script to the server. Alternatively, you could use wget or curl to download the .zip file to the server and then the unzip command to unzip it.
A graphical SFTP client like FileZilla may help for the former approach. The Firefox add-on cliget may help for the latter, especially because the file is hosted on a password-protected web forum.
fromdos is just a utility program to convert a text file from DOS/Windows format to Unix format by stripping out all the carriage return characters. Perhaps using this command is necessary because the author of the script used a Windows text editor or an ASCII-mode FTP transfer before zipping up the file. Of course, you need the file on the server if you are trying to run the command on the server.