Forum: help-en

Monitor Forum | Start New Thread Start New Thread
RE: "No Such File or Directory" When Decrypting Files Created with gpgtar [ Reply ]
By: Reed Hanger on 2021-03-05 15:31
[forum:7760]
Thanks, I upgraded to the latest version today but still had the same error with gpgtar.

But... I just tried a different way to run gpgtar and found a workaround. Instead of passing along multiple relative paths to each file, I copied the files into a temporary folder (to exclude all other files in those folders), replicating their old folder hierarchy, then just ran gpgtar to compress that folder. Kleopatra had no errors when I opened up the output file.

To save time, I'm not going to edit the folder names this time... So, instead of running this:
> cd \git
> gpgtar --recipient "Reed Hanger" --output=temp.tar.gpg --encrypt DevOps-IaC\DevVpc\terraform\terraform.tfvars DevOps-IaC\PerfVpc\terraform\terraform.tfvars DevOps-IaC\ProdVpc\terraform\terraform.tfvars DevOps-IaC\devops\terraform\secretvalues.tf

I ran this...
> cd \git
> cp DevOps-IaC\DevVpc\terraform\terraform.tfvars temp\DevOps-IaC\DevVpc\terraform\terraform.tfvars
> cp DevOps-IaC\PerfVpc\terraform\terraform.tfvars temp\DevOps-IaC\PerfVpc\terraform\terraform.tfvars
> cp DevOps-IaC\ProdVpc\terraform\terraform.tfvars temp\DevOps-IaC\ProdVpc\terraform\terraform.tfvars
> cp DevOps-IaC\devops\terraform\secretvalues.tf temp\DevOps-IaC\devops\terraform\secretvalues.tf
> cd temp
> gpgtar --recipient "Reed Hanger" --output=temp.tar.gpg --encrypt DevOps-IaC

Not ideal, but definitely workable. I guess gpgtar doesn't work well with multiple relative file paths?

RE: "No Such File or Directory" When Decrypting Files Created with gpgtar [ Reply ]
By: Bernhard Reiter on 2021-03-05 08:06
[forum:7755]
Hi Reed,
two suggestions

a) upgrade to the latest verison of gpg4win. (I do not remember specific improvements to gpgtar, but there well may haven been some small fixes along the way which do affect you.)

b) If 3.1.15 still exposes the problem, it potentially is a defect of gpgtar. So it should be filed at dev.gnupg.org. To get a faster result, you can try to see if you can reproduce the problem on a GNU/Linux system as well for the report.

Best Regards,
Bernhard

"No Such File or Directory" When Decrypting Files Created with gpgtar [ Reply ]
By: Reed Hanger on 2021-03-04 17:54
[forum:7754]
I'm trying to write a script to grab several files with the same name in different directories (and preserve the folder paths) and encrypt them all into one file. I also want to be able to decrypt it with the GUI. I have no problems when I encrypt the files manually via Kleopatra, but when I use gpg/gpgtar to encrypt I just get errors when trying to decrypt them.
To keep it simple, I didn't sign it and just used myself as the recipient when testing, but I can't even get that to work.

First I tried using gpgtar:
> gpgtar --recipient "Reed Hanger" --output=temp.tar.gpg --encrypt folder1\file.tfvars folder2\file.tfvars folder3\file.tfvars

I got no errors when encrypting, but both Kleopatra and gpgtar threw an error when I tried to decrypt it:
> gpgtar --decrypt temp.tar.gpg
gpgtar: C:\Program Files (x86)\GnuPG\bin\gpg.exe: gpg: encrypted with 2048-bit RSA key, ID AD17D8A0E18BA606, created 2020-03-04
gpgtar: C:\Program Files (x86)\GnuPG\bin\gpg.exe: "Reed Hanger <omitted>"
gpgtar: error creating 'temp.tar_1_/folder1/file.tfvars': No such file or directory


Next attempt, I skipped crypto on gpgtar and passed its output to gpg to encrypt, as I noticed Kleopatra seemed to do this:
> gpgtar --skip-crypto --encrypt folder1\file.tfvars folder2\file.tfvars folder3\file.tfvars | gpg --encrypt --recipient "Reed Hanger" --output=temp2.tar.gpg

...but I get the exact same error as before in both Kleopatra and gpgtar when I try to decrypt:
error creating 'temp2.tar_1_/folder1/file.tfvars': No such file or directory

If I decrypt the file with gpg and extract its output with tar.exe, it reports that the archive is damaged, and I can see one of the files is missing data.


For my third attempt, I figured I'd skip gpgtar altogether on the encryption process and just use gpg to encrypt a tar.
> tar --create --file=manual.tar folder1\file.tfvars
> tar --append --file=manual.tar folder2\file.tfvars
> tar --append --file=manual.tar folder3\file.tfvars
> gpg --encrypt --recipient "Reed Hanger" --output=manual.tar.gpg manual.tar

...but when I open that file in Kleopatra or try to decrypt it with gpgtar, I get even more errors. I'm guessing tar has different formats or gpgtar does something special.
> gpgtar --decrypt manual.tar.gpg
gpgtar: C:\Program Files (x86)\GnuPG\bin\gpg.exe: gpg: encrypted with 2048-bit RSA key, ID AD17D8A0E18BA606, created 2020-03-04
gpgtar: C:\Program Files (x86)\GnuPG\bin\gpg.exe: "Reed Hanger <omitted>"
gpgtar: [?]: invalid octal number encountered - assuming 0
gpgtar: [?]: invalid octal number encountered - assuming 0
gpgtar: [?]: invalid octal number encountered - assuming 0
gpgtar: error creating 'manual.tar_1_/./folder1/file.tfvars': No such file or directory

I can decrypt it with gpg and extract the output with tar.exe, as I've listed below, but for ease of use I'd really like this to work with the Kleopatra GUI.
> gpg --output=manualdecrypt.tar --decrypt manual.tar.gpg
gpg: encrypted with 2048-bit RSA key, ID AD17D8A0E18BA606, created 2020-03-04
"Reed Hanger <omitted>"
> tar -tf manualdecrypt.tar
./folder1/file.tfvars
./folder2/file.tfvars
./folder3/file.tfvars
> tar -xf manualdecrypt.tar

Any suggestions? I'm using Kleopatra Version 3.1.11-Gpg4win-3.1.11 on Windows 10 Pro version 1909