SSH Keys on Blue

From UVA Linux Users Group

Jump to: navigation, search


Contents

[edit] Intro

If you use linux the the standard openssh keys will not work on blue.unix because they run ssh.com's sshd. However, converting keys is easy.


[edit] Step by Step

First generate a temporary ssh key.

ssh-keygen -t dsa -f .ssh/tmpkey

Convert the key to ssh.com format, and rename the private key

ssh-keygen -e -f .ssh/tmpkey.pub > .ssh/id_dsa.pub
mv .ssh/tmpkey .ssh/id_dsa

Scp public key to blue.unix,

scp .ssh/id_dsa.pub $USERNAME@blue.unix.virginia.edu:~/.ssh2/

Now edit your authorization file to point to the new key.

ssh $USERNAME@blue.unix.virginia.edu 'echo "Key     id_dsa.pub" >> ~/.ssh2/authorization'

If you have ssh-agent running (ubuntu 7.04 does), you can simply do

ssh-add 

and your done. If not then you need to edit your .xsession to fire ssh-agent up when your X loads up.

[edit] Example Session

$ssh-keygen -t dsa -f .ssh/tmpkey
 Generating public/private dsa key pair.
 Enter passphrase (empty for no passphrase):
 Enter same passphrase again:
 Your identification has been saved in tmpkey.
 Your public key has been saved in tmpkey.pub.
 The key fingerprint is:
 **************
$ssh-keygen -e -f .ssh/tmpkey.pub > .ssh/id_dsa.pub
$mv .ssh/tmpkey .ssh/id_dsa
$scp .ssh/id_dsa.pub $USERNAME@blue.unix.virginia.edu:~/.ssh2/
 scp: warning: Executing scp1.
 ....
$ssh $USERNAME@blue.unix.virginia.edu 'echo "Key id_dsa.pub" >> ~/.ssh2/authorization'
$ssh-add 
 Enter passphrase for /home/USER/.ssh/id_dsa: 
 Identity added: /home/USER/.ssh/id_dsa (/home/USER/.ssh/id_dsa)

[edit] Auto username

It is also convinient not to have to type USERNAME@blue.unix.virignia.edu. You can edit the ssh client config to use a specific username for a specific host. In .ssh/config

Host blue.unix.virginia.edu
   User $USERNAME

Where $USERNAME is your blue.unix ID, like ala3j.

[edit] Nautilus one right-click script

If you use nautilus then you can create custom right-click menus which make uploading files to your home directory easy. For example you can save the following scipt to ~/.gnome2/nautilus-scripts/scp2blue.sh and make it executable.

#!/bin/sh
if [ -d $1 ]; then
        scp -r "$1" blue.unix.virginia.edu:public_html/ 

elif [ -f $1 ]; then 
        scp "$1" blue.unix.virginia.edu:public_html/
fi 

Don't forget to

chmod ug+x ~/.gnome2/nautilus-scripts/scp2blue.sh