[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: ssh-agent without graphical display manager? how?



On Sunday 04 January 2009, Paul E Condon <pec@mesanetworks.net> wrote 
about 'ssh-agent without graphical display manager? how?':
>I control it mostly by logging into it
>using ssh.  But when I log in this way, it appears that ssh-agent is
>not started.  Has anyone confronted
>this situation and worked out a solution? Advice?

I use the "keychain" package plus these scripts and snippets to start and 
load my agents:
(Helper scripts)
~/bin/keychain-start.sh: (Meant to be sourced)
#! /bin/sh
# Starts keychain or initializes the environment, but requires no 
interactivity.
if [ -x /usr/bin/keychain ]; then
        eval "$(/usr/bin/keychain --eval --quiet --inherit any-once --stop 
others --noask --lockwait 0 >/dev/null 2>&1)"
fi

~/bin/keychain-load.bash: (Meant to be run normally)
#! /bin/bash
# Starts and loads the keychain, interacting with the user as needed.
# May start gnupg-agent, but doesn't prompt for keys because gnupg-agent
# regularly times out keys.
# Since interaction is clearly available, we clear the keychain before 
adding
# keys (assume user is an attacker).
if [ -x /usr/bin/keychain ]; then
        SSH_KEYS=('id_dsa')
        eval "$(/usr/bin/keychain --eval --inherit any-once --stop others \
                --clear "${SSH_KEYS[@]}")"
fi

(KDE)
~/.kde/env/keychain-start.sh is a hardlink to ~/bin/keychain-start.sh.

~/.kde/env/ssh-askpass.sh: (optional)
#! /bin/sh

if [ -x /usr/bin/ksshaskpass ]; then
        SSH_ASKPASS=/usr/bin/ksshaskpass; export SSH_ASKPASS
elif [ -x /usr/bin/x11-ssh-askpass ]; then
        SSH_ASKPASS=/usr/bin/x11-ssh-askpass; export SSH_ASKPASS
elif [ -x /usr/lib64/ssh/x11-ssh-askpass ]; then
        SSH_ASKPASS=/usr/lib64/ssh/x11-ssh-askpass; export SSH_ASKPASS
elif [ -x /usr/bin/ssh-askpass ]; then
        SSH_ASKPASS=/usr/bin/ssh-askpass; export SSH_ASKPASS
elif [ -x /usr/lib64/ssh/ssh-askpass ]; then
        SSH_ASKPASS=/usr/lib64/ssh/ssh-askpass; export SSH_ASKPASS
fi

~/.kde/Autostart/keychain-load.desktop:
[Desktop Entry]
Name=Load Keychain
Comment=Start agents and add keys to them.
Exec=/home/bss/bin/keychain-load.bash
Terminal=true
StartupNotify=false
Type=Application
Encoding=UTF-8

(bash)
~/.bashrc:
[...]
if [ -x ~/bin/keychain-start.sh ]; then
        . ~/bin/keychain-start.sh
fi
[...]

~/.bash_profile:
[...]
[[ -t 0 ]] && [[ -x ~/bin/keychain-load.bash ]] && ~/bin/keychain-load.bash
[...]

If you use a different shell, then you may need to modify a differnt .*rc 
file and/or a different .*profile file.  If you use a different DE, you'll 
probably have to change the location of the DE files.
-- 
Boyd Stephen Smith Jr.                     ,= ,-_-. =. 
bss@iguanasuicide.net                     ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' 
http://iguanasuicide.net/                      \_/     

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: