unable to decrypt .asc file using databricks - python-3.x

I have 1 .zip.asc file ,inside that 3 txt files are there. I am trying to decrypt the test.zip.asc using below code but not working ,though while using tool it is working fine.
Databricks code
%sh
#Apply looping for each file in the source folder.
for entry in /dbfs/mnt/acc/Temp/*
do
#Create input variable
input=test.zip.asc
echo $input
#create output variable
output=test.zip
echo=$output
#import private key
gpg --no---batch --import /dbfs/mnt/acc/pgp/PrivateKey.asc
#start decryption
gpg --no--tty --batch --yes --ignore-mdc-error --pinentry-mode=loopback --passphrase-fd 1 --passphrase-file /dbfs/mnt/acc/pgp/Passphrase.txt --output /dbfs/mnt/acc/out/$output --decrypt /dbfs/mnt/acc/input/$input
done
output I'm getting
test.zip.asc
test.zip
gpg:no valid openPGP data found.
gpg:Total number proessed:0
gpg:enrypted with RSA key ,ID A48FAF69A4E7B316
gpg:decryption failed : No secret key

Related

How Can I Sign Commit With Gpg In Deepin Linux ( Zero To Hero )

I want to sign commit with gpg in linux , In windows i can sign , but in linux I have problem . I searched for this error in stackoverflow and github , but they cant solve my problem.
Gpg Error
error: gpg failed to sign the data
fatal: failed to write commit object
.gitconfig
[user]
signingkey = 18BCF98498084997
name = Ali Azmoodeh
email = treeroot.ir#gmail.com
[commit]
gpgsign = true
[gpg]
program = gpg2
I use clion ide to commit my project
Input
git -c credential.helper= -c core.quotepath=false -c log.showSignature=false add --ignore-errors -A -f -- .idea/.gitignore CMakeLists.txt .gitignore .idea/first.iml .idea/modules.xml .idea/misc.xml main.cpp
next
git -c credential.helper= -c core.quotepath=false -c log.showSignature=false commit -F /tmp/git-commit-msg-.txt --
Output
error: gpg failed to sign the data
fatal: failed to write commit object
Then I run this command
gpg --status-fd=2 -bsau 18BCF98498084997
Output
gpg: skipped "18BCF98498084997": No secret key
[GNUPG:] INV_SGNR 9 18BCF98498084997
[GNUPG:] FAILURE sign 17
gpg: signing failed: No secret key
So, I open this location on clion Setting> Git> Configure GPG Key
Error
Cant find suitable private key
Error ScreenShot
Follow the instructions over at this link. It appears that CLion is not able to find the appropriate private key for the specified public key.

Is it possible to export a GPG private key without passphrase being provided in a prompt?

I would like to automate a GPG private key export so it runs without user interaction.
gpg --export-secret-keys my#email.com
I tried providing --batch --passphrase-fd 0 arguments both with passphrase being passsed as:
an argument --passphrase 'my-passhrase'
from stdin echo 'my-passphrase' | gpg ...
It didn't work. Is it even possible to export private keys without user interaction?
You should add --pinentry-mode=loopback parameter, as well as --batch.
Full example from the RNP CLI tests suite:
gpg --batch --homedir .gpg ----pinentry-mode=loopback --yes --passphrase "password" --output keyfile.asc --export-secret-key userid

I'm trying to creat a SSH Key to use in my gitlab but the key file is empty

I used this command to create the key ssh-keygen -t ed25519 -C "francielefrederico#gmail.com" and it was successfully created but when I open the file ~/.ssh/id_ed25519.pub. to copy the key to my gitlab account, the file is empty.

Encrypt and decrypt files with password

I'm using linux and I basically want to encrypt a file using a password.
I've tried using gpg -c myfile for encryption, and that works fine, it asks me for a password and encrypts it. But it only asks for a password when encrypting.
I want a way to encrypt a file and if you want to decrypt it you have to give the same password that it was encrypted with.
If there's a python library that would work too since I can put that on a script.
There are several alternatives to create passowrd protected files under Linux.
GnuPG
GnuPG can be used to encrypt data and create digital signatures.
To encrypt and decrypt a data.txt file, use gpg command as follows:
$ gpg -c data.txt
$ gpg data.txt.gpg
mcrypt
mcrypt allows you to create password protected files similarly to GnuPG
To encrypt and decrypt a data.txt file, use mcrypt command as follows:
$ mcrypt data.txt
$ mcrypt -d data.txt.nc
OpenSSL
The OpenSSl Cryptography Toolkit can also be used to encrypt and decrypt files and messages.
To encrypt and decrypt a data.txt file, use the openssl command as follows:
$ openssl enc -aes-256-cbc -salt -in data.txt -out data.txt.enc
$ openssl enc -aes-256-cbc -d -in data.txt.enc -out data.txt
That's because of gpg-agent, a daemon that manages private keys and which is used as a backend for gpg. It caches your passphrases for some time by default. You can configure that with the following options (from man gpg-agent):
--default-cache-ttl n
Set the time a cache entry is valid to n seconds. The default is 600 seconds. Each time a cache entry is accessed, the entry's timer is reset. To set an entry's maximum
lifetime, use max-cache-ttl. Note that a cached passphrase may not evicted immediately from memory if no client requests a cache operation. This is due to an internal
housekeeping function which is only run every few seconds.
--max-cache-ttl n
Set the maximum time a cache entry is valid to n seconds. After this time a cache entry will be expired even if it has been accessed recently or has been set using gpg-
preset-passphrase. The default is 2 hours (7200 seconds).
One way to clear the cache is to reload the gpg-agent : gpgconf --reload gpg-agent
You can use gpg -c myfile && gpgconf --reload gpg-agent to encrypt your file, after which the password will be asked if you try to decrypt it with gpg myfile.gpg

I want to modify this bash script to not ask for password for each file

I want to modify this bash script to not ask for password for each file but look for password in the following file /home/user/Documents/pass.txt
I got this nice script on GIT hub and it works but it prompts me for passphrase for each file I want to encrypt, I would like to modify the script to seek password from a text file in /home/user/Documents/pass.txt and read the password in the pass.txt file and encrypt all files in the directory using siad password
Please Help I have been doing this manually for the past 2 weeks
#!/bin/bash
# This uses gpg to encrypt every file in a directory as separate
# encrypted files
# Usage
# ./encrypt-all.sh ./dir-of-files-to-encrypt "PASSPHRASE"
FILES="$1"
PASSPHRASE="$2"
pushd $FILES
for file_name in ./*; do
enc_name="$file_name.gpg"
echo "Encrypting $file_name"
gpg \
--passphrase "$PASSPHRASE" \
--batch \
--output "$file_name.gpg" \
--symmetric \
--cipher-algo AES256 \
"$file_name"
echo "Done! Output: $gpg_name"
done
popd
Use --passphrase-file instead of --passphrase, to indicate the name of the file whose first line is the passphrase to use.

Resources