Aerospace



Home

Company Information

Information Request

Linux How-to Guides

ADSP 21xx
Digital Signal Processing
Tutorials

SW Utilities

On-line Order Form

Aerospace Projects

Commercial Projects

Circuit Boards

Server Support


Bonk

Have you found this site useful? Did we save you time? Did we cure your head-ache? Is your hair growing back now?

Please make a donation to help with maintenance.


SSH Login Automation Howto

Mandrake Linux 10.0
Copyright Aerospace Software Ltd, GPL, 2004


Scope

This guide describes how to configure a system so that the SSH private key will be managed automatically by ssh-agent, without any user intervention, using a Expect script.

This places the private key passphrase inside a script file, which is not secure, but in the case where you have hundreds of clueless users, hiding the passphrase inside a script is more secure than telling them all what the passphrase is and then having it written down on a hundred sticky notes...

See the ssh-agent howto guide for more details on the configuration of ssh with public keys.


Bash Profile

Edit file ~/.bash_profile and add the following to the bottom:

# Run the ssh-agent
# Export SSH_AUTH_SOCK and SSH_AGENT_PID by using eval
eval `ssh-agent`
# Use Expect to feed the passphrase to ssh-add
~/.add-dsa

This will run ssh-agent and then pass control to an expect script called .add-dsa.


Passphrase

Create an Expect script to feed the passphrase to ssh-add. Create file ~/.add-dsa as follows:

#! /usr/bin/expect
# Add my dsa passphrase to ssh-agent

spawn ssh-add
expect "id_dsa:"
send "my dsa passphrase\n"
expect eof
exit

This will run Expect, spawn ssh-add, send the passphrase to ssh-add, wait for it to finish and then exit.


Test

First make the new file .add-dsa executable:

$ chmod 700 .add-dsa

Then open a console and verify that the key was loaded into ssh-agent:

$ ssh-add -L

You should see the encrypted private key.


'Hope this helps!
Herman



Copyright © 2005-2008, Aerospace Software Ltd., GPL.