⭕Environment Variables
How to set up Environment Variables to help with Yubikey, GPG, and ykman.
These steps explain how to setup helpful Environment Variables
that you can use to manage your keys and software.
Launch Command Prompt in administrator mode.
❊ Managing Environment Variables
BACKUP
Select only one method. It's highly recommended you use the regedit version. You can save the backup.reg file somewhere on your desktop and then execute it by double-clicking if you need to restore your original environment variables.
regedit /e "%userprofile%\Desktop\my_user_env_variables.reg" "HKEY_CURRENT_USER\Environment"
PRINT
To print all environment variables on new lines:
-----------------------------
List All
-----------------------------
dir e
-----------------------------
List Specific
-----------------------------
Get-ChildItem -Path Env:\gpglong
❊ Command Prompt -> Set ENV -> Add
APPLICATIONS
A list of env variables required for Keybase.
$env:DokanLibrary1 = 'C:\Program Files\Dokan\Dokan Library-1.4.0\'
$env:DokanLibrary1_LibraryPath_x64 = 'C:\Program Files\Dokan\Dokan Library-1.4.0\lib\'
$env:DokanLibrary1_LibraryPath_x86 = 'C:\Program Files\Dokan\Dokan Library-1.4.0\x86\lib\'
$env:DokanLibrary2 = 'C:\Program Files\Dokan\DokanLibrary-2.0.6\er'
GPG SHORTCUTS
The following can be used to set your GPG key IDs to an environment variable so that you don't have to keep typing the gpg commands.
Change ABCDEF1234560
and ABCDEF1234561
to your own key IDs. You can get your key IDs by using the command gpg --list-secret-keys --keyid-format=long
setx /m KEY_ID1 "ABCDEF1234560"
setx /m KEY_ID2 "ABCDEF1234561"
Once you have applied these new variables, you can open Command Prompt
and type:
%KEY_ID1%
%KEY_ID2%
To call these variables in Powershell
, you need to call them a bit differently:
iex $env:KEY_ID1
iex $env:KEY_ID2
You can use your KEY_ID
variables in commands by executing:
gpg --expert --edit-key %KEY_ID1%
❊ Command Prompt -> Set ENV -> Append
This is a list of commonly needed environment variables for this guide. Make sure you check the paths to ensure that yours are the same.
The following command can be used to append to your existing PATH
.
The commands below will APPEND whatever is currently set for PATH and add the new path to the end of the line. Check the paths on these before you add them as your paths may be different:
$env:Path += ';C:\Program Files\Yubico\YubiKey Manager CLI\'
$env:Path += ';C:\Program Files\Git\bin'
$env:Path += ';C:\Program Files\Yubico\Yubico PIV Tool\bin'
$env:Path += ';C:\Program Files (x86)\Gpg4win\bin'
$env:Path += ';C:\Program Files\Yubico\Yubico Challenge Response\bin'
$env:Path += ';C:\Program Files\OpenSSL-Win64\bin'
$env:Path += ';C:\Program Files\PuTTY\'
$env:Path += ';C:\Program Files\Yubico\YubiKey Manager'
$env:Path += ';E:\Libraries\Git\cmdn'
$env:Path += ';I:\SoftHSM2\lib'
$env:Path += ';F:\OpenSSH-Win6'
Last updated
Was this helpful?