22.11.2014 Views

Using OpenSSH with smartcards Why use OpenSSH with smart ...

Using OpenSSH with smartcards Why use OpenSSH with smart ...

Using OpenSSH with smartcards Why use OpenSSH with smart ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Using</strong> <strong>OpenSSH</strong> <strong>with</strong> <strong><strong>smart</strong>cards</strong><br />

ModLength : 2048<br />

Key ref : 0 (0x0)<br />

Native : yes<br />

Path : 3f0050152900<br />

Auth ID : 01<br />

ID : 7645d913d5b4e03f3fe5*****f02324c23a7ebf<br />

Now extract the RSA key in SSH format:<br />

$ pkcs15-tool --read-ssh-key 7645d913d5b4e03f3fe5*****f02324c23a7ebf4<br />

<strong>Using</strong> reader <strong>with</strong> a card: OmniKey CardMan 4321 00 00<br />

Please enter PIN [User PIN]:<br />

2048 65537 258115708996235*****134757454178319<br />

ssh-rsa AAAAB3NzaC*****ed0aZdx9FFu/w6l7P5KsndWgP<br />

Notice the RSA public key in SSH format:<br />

ssh-rsa AAAB3NzaC*****ed0aZdx9FFu/w6l7P5KsndWgP<br />

Installing public key on <strong>OpenSSH</strong> server<br />

In this section we will copy your public RSA key to the ~/.ssh/authorized_keys file on server.<br />

The .ssh notation denotes a hidden folder.<br />

This folder should be inside the home of the <strong>use</strong>r connecting.<br />

Please notice that on the server, the .ssh folder may not exist.<br />

In which case you will need to create it.<br />

In our example, we check that the .ssh exist:<br />

$ ls -lh /home/fperou/.ssh<br />

authorized_keys<br />

If the .ssh folder does not exist, create it using the <strong>use</strong>r account:<br />

$ mkdir ~/.ssh<br />

$ touch ~/.ssh/authorized_keys<br />

Copy the content of the public key (on <strong>smart</strong> card) to the ~/.ssh/authorized_keys file (on server). In our example:<br />

ssh-rsa AAAAB3NzaC1yc2EAAAADAQ********9FFu/w6l7P5KsndWgP<br />

<strong>Using</strong> ssh <strong>with</strong> <strong>smart</strong> cards<br />

In our example, we log using ssh client, <strong>use</strong>r 'fperou' on remote server 'remotehost':<br />

GNU/Linux:<br />

$ ssh -I /usr/lib/opensc-pkcs11.so fperou@remotehost<br />

Enter PIN for 'FRANCOIS PEROU (User PIN)':****<br />

Copyright GOOZE 2010-2011 http://www.gooze.eu 8 / 15

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!