I have file in linux which I need to do the PGP encryption.
Through manually I am using this command to do the same
gpg -c scsrun.log
Enter passphrase :
Repeat Passphrase :
But how I can achive this using linux script.
Thanks
I have file in linux which I need to do the PGP encryption.
Through manually I am using this command to do the same
gpg -c scsrun.log
Enter passphrase :
Repeat Passphrase :
But how I can achive this using linux script.
Thanks
From man gpg:
--passphrase-fd n
Read the passphrase from file descriptor n. If you use 0 for n, the
passphrase will be read from stdin. This can only be used if only one passphrase
is supplied. Don't use this option if you can avoid it.
So perhaps:
# Open password file into FD 5
exec 5</path/to/passwordfile
gpg --passphrase-fd 5 ...
# Close file
exec 5<&-
The passphrase file should be a file with 600 or less permissions, inside a folder with 700 or less permissions -- readable only by you, in other words.
Do i need to create the Public key ,if yes could you please provide the steps.
In this case I am storing the password in the file which can read by any other person. If there is any other mechnism to enrypt that pasword and use this in the script
That's what file permissions are for, and why I told you what file permissions were necessary.
This is a common fallacy. No. If the script can decrypt it, so can anyone else, by reading the script. Keeping the script properly secured is no better than keeping the file properly secured, which you could have done in the first place.