SSH with passphrase

From ICT science
Revision as of 09:49, 19 September 2013 by Ruule101 (talk | contribs) (Created page with "The following recipe works on both Mac OSX and Linux. First log in on computer ''A'' as user ''a'' and generate a pair of authentication keys, open Terminal: A:~ a$ ssh-keygen...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The following recipe works on both Mac OSX and Linux.

First log in on computer A as user a and generate a pair of authentication keys, open Terminal:

A:~ a$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/a/.ssh/id_rsa): 
Created directory '/Users/a/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/a/.ssh/id_rsa.
Your public key has been saved in /Users/a/.ssh/id_rsa.pub.
The key fingerprint is:
95:9f:a5:6a:d0:2d:82:68:6f:9c:c5:38:20:e4:e5:7c a@A.phys.uu.nl

Now use ssh to create a directory ~/.ssh as user ‘solisid’ on staff.science.uu.nl (the directory may already exist)

A:~ a$ ssh ‘solisid’@staff.science.uu.nl mkdir –p .ssh
‘solisid’@staff.science.uu.nl's password: 

Finally append a’s new public key to

‘solisid’@staff.science.uu.nl:.ssh/authorized_keys2

and enter password for ‘solisid’@staff.science.uu.nl (not passphrase)

A:~ a$ cat .ssh/id_rsa.pub | ssh ‘solisid’@staff.science.uu.nl 'cat >> .ssh/authorized_keys2'
‘solisid’@staff.science.uu.nl's password: 
SSH-with-passphrase.png

From now on you can log into staff.science.uu.nl from A with passphrase (image on right for Mac OSX only).

A:~ A$ ssh ‘solisid’@staff.science.uu.nl
Last login: Wed Sep 18 12:41:48 2013 from A.phys.uu.nl

*********************************************************************
*                 Welcome to staff.science.uu.nl                    * 
*                                                                   * 
*      This is Scientific Linux 5.5 (www.scientificlinux.org)       *
*     Hardware: Dual Quad Core AMD 2378 @2.4 GHz, 32 Gb memory      *
*                                                                   *
*              Questions and software requests:                     *
*                https://ict-servicedesk.uu.nl                      *
*********************************************************************
*       Do you want to run multiple "background-jobs" ?             *
*            ALWAYS USE THE BATCH SYSTEM ! (bonus is higher Prio!)  *
*    Please read the man-pages first                                *
*    % man sge_intro  ; for usage of the batch system               *
*    % man qsub       ; for job submission                          *
*                                                                   *
*    Check current queue status                                     *
*    % qstat -f -ne -u "*"                                          *
*********************************************************************
* HISTORY:                                                          *
* <>                                                                *
* 26-03-2013 :  Matlab R2013a      (/usr/local/MATLAB/R2013a/bin)   *
* 26-03-2013 :  Maple17            (/usr/local/maple/maple17/bin)   *
* 31-05-2013 :  R (V3.0.1)         (/usr/local/R-3.0.1/bin/R)       *
*********************************************************************
-bash-3.2

Change the permissions of .ssh to 700

-bash-3.2$ chmod 700 .ssh

Change the permissions of .ssh/authorized_keys2 to 600

-bash-3.2$ chmod 600 .ssh/authorized_keys2