Gnuk

From Noisebridge
(Difference between revisions)
Jump to: navigation, search
(Created page with "'''Using Gnuk on FST-01 GPG Token on Debian Wheezy ''' This is a quick tutorial on how to get your public and private key to work with the Flying Stone Tiny[1] GPG token. All...")
 
Line 1: Line 1:
'''Using Gnuk on FST-01 GPG Token on Debian Wheezy
+
'''Using Gnuk on Debian Wheezy
 
'''
 
'''
  

Revision as of 16:52, 22 March 2013

Using Gnuk on Debian Wheezy

This is a quick tutorial on how to get your public and private key to work with the Flying Stone Tiny[1] GPG token. All the information here was taken from the complete documentation of Gnuk written by its author[2]. Benefits of the Flying Stone Tiny-01 include: a) keeping your secrets separated from a hard-disk, which is a common medium for the storage of GPG secrets and could potentially represent a major security risk; b) ability to use your keys in multiple computers; c) hardware-lock preventing the secrets to be read from the token; d) it is USB, which means it is (almost) universal, dipensing the need for a Smart Card reader, while having all the benefits of a smart card; d) it is all free software-based (GPLv3), therefore it is not only transparent and widely available, but also free for further improvements and new inventive usages.

After completing the tutorial, if you still have questions, access the Q&A forum [3] and check Riseup's tutorial [].


1. Check requerements for using the GPG token:

  - Your GPG keys must be RSA 2048 bits, if your keys do not met the requirement, generate new keys[4];
  - FST-01 USB token with Gnuk pre-installed (click here for alternatives);
  - GNU/Linux system (should work on other *nix systems, but not yet tested).


2. Install the following packages:

  - gnupg/gnupg2 (gnupg version >= 1.4 or gnupg2)
  - gpg-agent
  - gnupg-pkcs11-scd (substitute for scdaemon under 'Squeeze')
  - python-pyscard (to use a tool for removing keys)
     

3. Edit your GPG configuration:

Add the following content to your ~/.gnupg/gpg.conf file:

    use-agent
    personal-digest-preferences SHA256
    cert-digest-algo SHA256
    default-preference-list SHA512 SHA384 SHA256 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed
    default-key ADD_YOUR_KEY_ID_HERE   

4. In order to use the token, make sure you are running gpg-agent, if not:

Run gpg-agent:

    gpg-agent --daemon --enable-ssh-support


5. If you are planning to use the token to authenticate with OpenSSH

Generate your ssh keys [5]:

    gpgkey2ssh ADD_YOUR_SUBKEY_ID_HERE >> sshpubkey.txt
    

Add your pub key to the server you want to auth with your GPG token:

    ssh ~/.ssh/authorized_keys


6. Personalize your token

To change your personal info, URL where your pub key is, etc., run:

    gpg --card-edit
    
    gpg> admin
    Allow admin commands to be executed
    
    gpg> name
    Register name and surname of the token owner
    
    gpg> url
    Address for the location of your public keys, important setting to help you register the token in other machines

    gpg> passwd
    Set-up your PIN for the usage of the token, please this is not your 'passphrase' for the GPG private key
    The default PIN from the factory is "123456"; your new PIN should not be bigger than 8 characters.
    It does not have to be numbers -- the acronym PIN is misleading here.
    
    gpg> forcesig 
    This will change the default setting of 'signature force PIN' OFF
    
    gpg> login
    Register your login name
    
    gpg> help
    This is command is your friend, if you want to further customize the token!
    
    gpg> save
    This will apply the changes


7. Write your public and private GPG keys to the token

Invoke GPG shell with this command, adding your key ID where indicated:

    gpg --edit-key ADD_YOUR_KEY_ID_HERE
  
    gpg> keytocard 
    This command will *move* your pub GPG key to the token
    
    gpg> toggle
    This command changes from pub key to the private key operation
    
    gpg> keytocard
    This command will move your private key to the token
    
    gpg> save
    This command will save the info to the token and exit the shell


8. Using your keys in other computers with GPG installed

Invoke the GPG shell with this command:

    gpg --card-edit
    
    gpg> fetch
    This command will retrieve your keys and add it to the local GPG keychain
    

The key is now registered by your local install of GPG, but you have to set the trust of it:

    gpg --edit-key ADD_YOUR_KEY_ID_HERE
    
    gpg> trust
    This command will set the key you just installed as 'trusted'. Given it is your own key, set it to (5) 'ultimate' trust
    
    

9. Before you use the token, make sure you deactivate other gpg agents. Here are some popular agents:

  - gnome-keyring (GNOME)
  - kwallet (KDE)
  - seahorse 


10. Access '/etc/xdg/autostart' and '~/.config/autostart' and add a new entry to the following config files:

Add this line to 'gnome-keyring-ssh.desktop':

    X-GNOME-Autostart-enabled=false
  

Add this line to 'gnome-keyring-gpg.desktop':

    X-GNOME-Autostart-enabled=false


11. Common Issues

  * If you get the 'OpenPGP card not available: general error', try killing gpg-agents, such as gnome-keyring;
  * If you type a wrong PIN three times, you will lock the device permanently, *be extra carefull*!
  * If you need to re-write keys to the token, make sure to delete the keys on it first [6].


12. Sources

[1] http://www.seeedstudio.com/wiki/FST-01

[2] http://www.fsij.org/doc-gnuk/

[3] http://no-passwd.net/askbot/questions/scope:all/sort:activity-desc/page:1/

[4] http://keyring.debian.org/creating-key.html

[5] http://www.programmierecke.net/howto/gpg-ssh.html

[6] http://no-passwd.net/askbot/question/51/how-to-deletereplace-the-key-in-gnuk/

[7] https://we.riseup.net/debian/using-the-openpgp-card-with-subkeys

Personal tools