Public key ssh login

From Biowikifarm Metawiki
Jump to: navigation, search

Setup on your local machine (Linux)

(TODO check if there is an more convenient and less complicate way)

Generate a public key (for the remote server) and a private key (only on your local machine) with comment within the key:

ssh-keygen -C 'firstname lastname <my-email-address@as-comment.com>'

Enter file in which to save the key (/home/myusername/.ssh/id_rsa): ‹provide NO file here!!›
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/myusername/.ssh/id_rsa.
Your public key has been saved in /home/myusername/.ssh/id_rsa.pub.

Now in the hidden .ssh directory of your home directory exist 2 additional files: id_rsa (your private key) and id_rsa.pup (your public key)

Send only the public key (id_rsa.pub) to your server admin.

Now the ssh-agent must be running. There are different ways to accomplish this. According to Mark A. Hershberger's blog “Using ssh-agent with ssh” you can add the following lines to your profile file (in /home/yourusername/.profile or simply ~/.profile):

SSHAGENT=/usr/bin/ssh-agent
SSHAGENTARGS="-s"
if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then
  eval `$SSHAGENT $SSHAGENTARGS`
  trap "kill $SSH_AGENT_PID" 0
fi

Add the new keys by calling:

ssh-add

Now it should work. (done so on a local Linux OpenSuse 12.1 by --Andreas Plank 21:17, 11 February 2012 (CET))