Tommy Hoang
Tommy Hoang

Reputation: 355

Export and Import the specific GPG key only

I am using Linux 24.04 and have multiple GPG keys on same machine. I want to tell Git my Project A to use GPG A, Project B will use GPG B, e.g. Each project has Makefile as following:

show_gpg_info:
    @echo "\nYour current GPG list:"
    @gpg --list-secret-keys --keyid-format=long
    @echo "Please choose one GPG ID and input the corresponding information to continue."

choose_gpg_key:
    @read -p "Choose email: " input_email;
    @read -p "GPG ID: " input_gpg_key;
    @read -p "Your name: " input_full_name;

export_import_gpg_keys:
    @gpg --export $(input_email) > gpg-public.key
    @gpg --import gpg-public.key
    @gpg --export-secret-key $(input_email) > gpg-private.key
    @gpg --import gpg-private.key

When I run the Makefile, I want to export one key for one project but in fact, it always export and import all keys existed in my machine. It seems $(input_email) provided empty value but when I echo variables, they were right value recorded. Any idea?

Upvotes: 0

Views: 42

Answers (0)

Related Questions