Buenas, estoy empezando en esto, y estso dearrollando un script basico...
necesito que me digais como pongo contraseña a un documento, ya lo e intentado con "gpg", pero no me ha ido. Aqui os lo dejo
#!/bin/bash
read -p "Ingresa opcion a: " opcion
read -p "Ingresa opcion b: " opcionb
if [ "$opcion" = "$opcionb" ]; then
if [ ! -d /root/Escritorio/Resultados ]; then
mkdir /root/Escritorio/Resultados
touch /root/Escritorio/Resultados/resultado
echo las variables son iguales >> /root/Escritorio/Resultados/resultado
else
touch /root/Escritorio/Resultados/resultado
echo las variables son iguales >> /root/Escritorio/Resultados/resultado
fi
elif [ ! "$opcion" = "$opcionb" ];then
if [ ! -d /root/Escritorio/Resultados ]; then
mkdir /root/Escritorio/Resultados
touch /root/Escritorio/Resultados/resultado
echo las variables no son iguales >> /root/Escritorio/Resultados/resultado
else
touch /root/Escritorio/Resultados/resultado
echo las variables no son iguales >> /root/Escritorio/Resultados/resultado
fi
fi
read -p "Desea poner contraseña al archivo resultado?: " respuesta
if [ "$respuesta" = si ]; then
gpg -c /root/Escritorio/Resultados/resultados.txt
if [ "$respuesta" = no ]; then
fi
fi
exit 0
La manera de usar gpg es:
gpg -c archivo
Ejemplo:
[0 [19:04][leo@archero Desktop]$ cat file.txt
url1
url2
url3
url4
[0 [19:04][leo@archero Desktop]$ gpg -c file.txt
gpg: directory `/home/leo/.gnupg' created
gpg: new configuration file `/home/leo/.gnupg/gpg.conf' created
gpg: WARNING: options in `/home/leo/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/home/leo/.gnupg/pubring.gpg' created
[0 [19:04][leo@archero Desktop]$ cat file.txt
file.txt file.txt.gpg
[0 [19:04][leo@archero Desktop]$ cat file.txt.gpg
���+���`�-9�����B�U���{[|-�Lzcz:̨��%N�m�S�pRL����][0 [19:05][leo@archero Desktop]$
[0 [19:05][leo@archero Desktop]$
Ahora si quieres descifrar dicho archivo:
gpg archivo.gpg
Ejemplo
[0 [19:05][leo@archero Desktop]$ gpg file.txt.gpg
gpg: keyring `/home/leo/.gnupg/secring.gpg' created
gpg: CAST5 encrypted data
gpg: encrypted with 1 passphrase
File `file.txt' exists. Overwrite? (y/N) y
gpg: WARNING: message was not integrity protected
[0 [19:05][leo@archero Desktop]$