GPG Key Import to Another PC
We have provided a set of commands for working with GPG keys, encrypting and decrypting files, and extracting tar archives. These commands are useful for various tasks related to data security and file management. Here’s a breakdown of each command with a brief explanation:
|
|
-
The
scp
command is used to securely copy the GPG private key file (example-backup-enc-privkey.asc
) to another PC with the specified IP address and destination folder (~
denotes the user’s home directory). -
gpg --import
is used to import the GPG private key into the GPG keyring on the destination PC. -
gpg --edit-key [email protected]
opens an interactive prompt for editing the key with the specified email address. -
Inside the interactive prompt,
trust
sets the trust level of the key, and5
represents “I trust ultimately.” This level indicates a high level of trust in the key.
GPG Encrypt File
|
|
- This command is used to encrypt a file (
test.data
) using GPG. The--recipient
flag specifies the recipient’s name or key ID. In this case, it’s “Example Backup.”
GPG Decrypt File
|
|
- This command decrypts a GPG-encrypted file (
test.data.gpg
) and saves the decrypted content to a file namedtest.data.output
. Make sure you have the necessary decryption key to perform this operation.
GPG Remove Secret Key
|
|
-
The first command,
gpg --list-secret-keys
, lists your secret keys. -
The second command,
gpg --delete-secret-keys <YOUR-SECRET-KEY>
, deletes the specified secret key from your keyring. Replace<YOUR-SECRET-KEY>
with the appropriate key ID.
Extract Tar Archive (Preserving Permissions)
|
|
- This set of commands navigates to the destination folder (
cd /path/to/destination/folder
) and extracts the contents of a tar archive (put_your_name_here.tar.gz
) while preserving file permissions and ownership.
Extract Tar Archive (Specific Folder)
|
|
- This command extracts the contents of the
foo.tar
archive into the current directory (-C ./
) and specifically targets the folderhome/foo/bar
within the archive for extraction.
Please note that these commands should be used with caution, especially when dealing with GPG keys, as mishandling them can result in data loss or security issues. Always ensure you have backups and understand the implications of the commands you’re using.