SSH Agent

From wiki.sixohthree.com
Jump to: navigation, search

ssh-agent allows you to share a key between computers so a password is not required to connect securely. This key can be password protected. Mark Hershberger has a tutorial on setting up ssh-agent and creating an id_dsa/id_dsa.pub key set.

This code can be placed in .bashrc to keep a connection to ssh-agent active:

#
# ssh-agent connection
#

# are we inheriting an agent?
if [ -z "$SSH_AUTH_SOCK" ]; then
        # does it exist at all?
        if [ -f ~/.ssh-agent-info ]; then
                # we had info once.
                . ~/.ssh-agent-info &>/dev/null
        fi
fi

# we've exhausted our options for connecting to
# an open agent. is it valid?
ssh-add -l &>/dev/null
EXITCODE=$?

if [ "$EXITCODE" != "0" ]; then
        # invalid. make new.
        ssh-agent > ~/.ssh-agent-info
        . ~/.ssh-agent-info &>/dev/null
        ssh-add ~/.ssh/id_dsa &>/dev/null
fi

Portions taken from Ted Dustman's No More Passwords (with SSH). Looks like he has his own script for this, as well.

[edit] SSH Agent at RIT =

The Rochester Institute of Technology uses the commercial version of SSH on the Digital UNIX Grace cluster (grace.rit.edu). ssh-keygen has two flags used to convert keys to the necessary format for an SSH server:

ssh-keygen -i keyfile
Convert a public (or private) key to an OpenSSH-compatible public (or private) key.
ssh-keygen -e keyfile
Create a public key file suitable for use on commercial SSH servers.

(Consider this untested; feel free to update this page if you can verify the accuracy of this information.)

Here is my ~/.ssh/config file for use in the office:

Host grace.rit.edu grace
        IdentityFile ~/.ssh/macrcs-ambhelp
        User macrcs
        HostKeyAlias grace.rit.edu
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox