GNU Privacy Guard: Difference between revisions
m Text replacement - " {{Navbox Linux}}" to "" |
m Text replacement - "Category:Linux" to "Category:Linux{{Navbox Linux}}" |
||
| Line 155: | Line 155: | ||
[[Category:Todo]] | [[Category:Todo]] | ||
[[Category:Linux]]{{Navbox Linux}} | [[Category:Linux]]{{Navbox Linux}}{{Navbox Linux}} | ||
[[Category:LinuxUtilities]] | [[Category:LinuxUtilities]] | ||
Revision as of 05:08, 1 September 2019
GNU Privacy Guard (GPG or GnuPG) is a open source replacement for the original Pretty Good Privacy software suite. It is capable of encrypt and decrypt data.
Key Management
Creating a New Key
To generate a new key, run gpg --gen-key
# gpg --gen-key
gpg (GnuPG) 1.4.19; Copyright (C) 2015 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Please select what kind of key you want:
(1) RSA and RSA (default)
(2) DSA and Elgamal
(3) DSA (sign only)
(4) RSA (sign only)
Your default key can be set by setting the GPGKEY environment variable.
Listing Keys
gpg --list-keys
# gpg --list-keys
/home/leo/.gnupg/pubring.gpg
----------------------------
pub 2048R/28AF4724 2015-11-23
uid Leo Leung <leo@steamr.com>
Deleting Keys
Delete the private key using gpg --delete-secret-keys, and the public key using gpg --delete-keys.
# gpg --delete-secret-keys 28AF4724
sec 2048R/28AF4724 2015-11-23 Leo Leung <leo@steamr.com>
Delete this key from the keyring? (y/N) y
This is a secret key! - really delete? (y/N) y
# gpg --delete-keys 28AF4724
pub 2048R/28AF4724 2015-11-23 Leo Leung <leo@steamr.com>
Delete this key from the keyring? (y/N) y
Adding another UID
Edit the key using gpg --edit-key and run then adduid command. Exit using the save command.
Sending a key to a key server
gpg --keyserver pgp.mit.edu --send-key ###
Changing Private Key Passphrase
$ gpg --edit-key [keyID]
Command> passwd
Enter passphrase:
Enter the new passphrase for this secret key.
Enter passphrase:
Repeat passphrase:
Command> save
Exporting Public Key
gpg --armor --export leo@steamr.com --output leo.steamr.pub
Basic Usage
Signing Files
There are a few types of signatures:
Binary Signature
The input file is compressed and its binary data is signed. GPG places the signature and compressed file contents into a .gpg file.
| Signing | gpg --clearsign test.txt
|
|---|---|
| Verifying | gpg --verify test.txt.gpg
|
| Retrieving | gpg -d -o test.txt test.txt.gpg
|
Clear Signature
The contents of the input file is signed in clear text. The signature and the contents of the input file are placed in clear text in a .asc file. This file can be viewed with any text editor and the signature and contents are fully visible.
| Signing | gpg --clearsign test.txt
|
|---|---|
| Verifying | gpg --verify test.txt.asc
|
| Retrieving | gpg -d -o test.txt test.txt.asc
|
Detached Signature
A signature for the input file is created and stored in a .sig file. Typically, the signature file is bundled with the input file with the same name except with the .sig file extension.
| Signing | gpg --detach-sign test.txt
|
|---|---|
| Verifying | gpg --verify test.txt.sig test.txt
|
Automating Encrypted Backups using Asymmetric Keys
#!/bin/sh
HOSTNAME=`hostname`
DATE=`date +%Y-%m-%d`
# Get the public key to encrypt with
wget -O - http://leo.home.steamr.com/public/backup_key.pub | gpg --import
# Create archive, pipe to gpg to encrypt, then send to freebsd
tar -czpf - \
/usr/share/sickbeard/ \
/etc/init.d/sickbeard \
\
/usr/share/SABnzbd/ \
/etc/init.d/SABnzbd \
\
/home/rt \
/var/www/html/rutorrent \
/usr/lib64/httpd/modules/mod_scgi.so \
/etc/httpd/conf.d \
/etc/httpd/conf/httpd.conf \
\
/etc/fstab \
/etc/passwd \
/etc/group \
/etc/shadow \
| gpg --encrypt --yes --no-tty --trust-model always --recipient leo@steamr.com \
| ssh backup@freebsd "cd /storage/backups/archived/sickbeard; cat - > $HOSTNAME.$DATE.tar.gz.gpg"
# Requires mailx, with smtp=smtp://mail.home.steamr.com set in /etc/mail.rc
echo -e "Backup Completed on `date`.\nUptime: `uptime`\n\nProcesses:\n`ps -eaf`" | mail -s "Backup Completed on `hostname`" "leo@home.steamr.com"
# delete the public backup key
gpg --batch --yes --delete-key leo@steamr.com
See Also
- https://www.gnupg.org/documentation/manuals/gnupg/Operational-GPG-Commands.html
- https://help.ubuntu.com/community/GnuPrivacyGuardHowto
Various Linux Notes - /etc/fstab
- Access.conf
- ACL
- Apache Proxy to Internal Server
- APM X-C1 (Mustang)
- ARP
- Authselect
- Bash Scripting
- Blockparser
- Booting Linux without a Graphics Card
- Building Container Images
- Burning CD/DVD in Linux
- Clear RAID Signatures on Linux
- Cobbler
- Colorized Terminal Outputs
- Compiling MIPS
- Configure Sendmail
- CPanel
- CPanel Fork Bomb Protection
- CPU Frequency Scaling
- Create a Linux User with an Empty Password
- Cron and PAM Issues
- Dell OpenManage
- Diff Two Command Outputs
- DirectAdmin
- Disable Filesystem Check on Startup
- DNS Ad Blocker
- Driver Disk
- Drop caches
- End / Home keys don't work in Terminal
- Entropy in the Linux Kernel
- Entropy Source using RTL-SDR
- Exit Codes
- Extract .exe Resources with dd
- File Attributes
- Fixing ixgbe unsupported SFP+ module type was detected
- Get Active Linux Virtual Console
- Getting Hardware UUID
- Hosts.deny
- How to change Linux desktop user directories
- How to hot-swap SATA disks on Linux
- HP Smart Storage Administrator
- Hyper-threading
- IBM Spectrum Archive
- IBM Spectrum Protect
- IBM Tape
- IBM Tape Diagnostic Tool
- InterWorx
- Kerberize NFS
- Kerberize SSH
- Linux Clustering
- Linux Fonts
- Linux Namespaces
- Linux Network Interface Naming
- Linux Nvidia Driver
- Linux Process Accounting
- Linux Uptime in Seconds
- Linux UTF-8 Font
- Mainline Kernel on CentOS 7
- Missing Fonts
- Mod fastcgi Install on Apache 2 / cPanel
- Mod fcgid
- Monitoring network traffic in Linux
- Mounting / Unmounting KVM Image
- Mounting Samba (CIFS) shares
- Multiple Networks on Linux
- MySQL Database with Hash Sign
- No Console Output
- Number of Files Opened
- Open OnDemand
- Packing and unpacking initrd
- PAM Issues
- Partition Alignment
- Patching a binary file with dd
- Perl Module Location
- Raspberry Pi
- Red Hat kickstart
- Red Hat to Debian
- Reverse SSH Tunnel
- Ruby on Rails under cPanel
- Rutorrent + rtorrent Installation Guide on CentOS 6.4
- Self Signed SSL Certificates
- Service Management
- Sick Beard
- StartSSL Free Certificate
- Symlink
- Taking a Screenshot in X11
- Timezone
- Tor
- TOR Transparent Proxy
- Traefik
- Troubleshooting a Slow Linux System
- Turning on swap with a page file
- Udev Rules
- Verify SSL Certificate matches Private Key
- VMware Workstation
- Webcam
- X Display Manipulation
- X Forwarding
Linux Tools and Utilites - Anaconda
- Ansible
- Aria2
- Autofs
- Awk
- Badblocks
- Bash Shell
- Binwalk
- Bosh
- Ceph
- Chntpw
- Chrony
- Clonezilla
- Cloud-init
- CloudStack
- Column
- Cron
- Curl
- Cvs2git
- Date
- Dbus
- Dd
- Dm-crypt
- Dovecot
- DRBD
- ElasticSearch
- Enroot
- Environment Module
- Envsubst
- Fail2ban
- FFmpeg
- Find
- Firecracker
- Flashrom
- Foreman
- FortiClient
- Fswebcam
- Galaxy
- Git
- Gnome
- Gobetween
- GPFS
- Grafana
- Grub
- Hdparm
- Home Assistant
- How to disable SELinux
- Htaccess
- Infiniband
- InfluxDB
- InfluxDB 1.x
- Insert a kickstart file into a iso image
- Inspircd
- IOzone
- Iperf3
- Ipmitool
- Irqbalance
- John The Ripper
- Lightdm
- Lm sensors
- Logrotate
- LSF
- LVM
- Lynx
- Mailx
- Md5sum
- Mdadm
- Midnight Commander
- Motion
- Mount
- Mutt
- Nomad
- OpenLDAP
- Openocd
- OpenSSL
- OpenVPN
- Packer
- PHP
- Pi-hole
- Postgres
- PowerBroker Identity Service
- Proxmox
- Pueue
- PulseAudio
- Puppet
- Quota
- Red Hat Satellite
- Restic
- Rsync
- Rtorrent
- Ruby
- Sabnzbd
- Sage
- Samba
- Screen
- Sed
- SELinux
- Sendmail
- Shell Configs
- Singularity
- Sleep
- Slurm
- SMART
- Sonarr
- Sqlite
- SquashFS
- Squid
- SSH
- Steam
- Stoken
- Strace
- Sudo
- Sync
- Sysctl
- Syslog
- Sysrq
- System Security Services Daemon (SSSD)
- Systemd
- Tar
- Tcsh
- Telegraf
- Terraform
- Thttpd
- Tmux
- Tomcat
- Top
- Umask
- Unix2dos
- Vim
- Virsh
- Virt-customize
- VirtualBox
- VirtualGL
- Visidata
- Vnstat
- Weechat
- Wget
- XFS
- Youtube-dl
- ZFS
- Zram
Package Management Linux Distributions Networking - Blazemeter
- CSF/LFD
- Exim
- Firewall
- FreeIPA
- Get DHCP Network Settings
- IP Aliasing
- Ipset
- IPTables
- IPv6
- IPXE
- Link Aggregation
- Linux Network Namespaces
- MTU
- Net-tools to iproute2
- Netcat
- Open vSwitch
- OpenWRT
- Postfix
- Raspberry Pi Torified Wifi
- Socat
- Static Routes
- StrongSwan
- Tcpdump
- Traffic Forwarder using IPTables
- Wi-Fi
- WireGuard
Containers