Skip to content

Commit

Permalink
re-do ssh-agent invokation
Browse files Browse the repository at this point in the history
  • Loading branch information
mslehto committed Sep 23, 2018
1 parent 30c2580 commit 8be7c03
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
34 changes: 34 additions & 0 deletions bin/ssh-agent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

. ~/.sshrc > /dev/null
ssh-add -l 2>/dev/null
rc=$?

if [ $rc -lt 2 ]
then
if [ $rc -lt 1 ]
then
echo "ssh-agent running already running, with identities"
else
echo "ssh-agent running already running"
fi
else
echo "ssh-agent not running, starting"
SSH_AUTH_SOCK=~/.ssh/agent.$$
ssh-agent -s -a $SSH_AUTH_SOCK > ~/.ssh/sshrc.new
. ~/.ssh/sshrc.new
rm -f ~/.ssh/sshrc.old
mv ~/.sshrc ~/.ssh/sshrc.old
mv ~/.ssh/sshrc.new ~/.sshrc
. ~/.sshrc
ssh-add -l 2>/dev/null
rc=$?
if [ $rc -lt 2 ]
then
rm -f ~/.ssh/agent.socket
ln -s $SSH_AUTH_SOCK ~/.ssh/agent.socket
echo "SSH_AUTH_SOCK=~/.ssh/agent.socket; export SSH_AUTH_SOCK;" >> ~/.sshrc
else
echo "ssh-agent startup failed rc=$rc"
fi
fi
5 changes: 2 additions & 3 deletions shrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ alias mv='mv -i'
alias rm='rm -i'
alias vi='vim'

#. ~/.ssh-agent.sh > /dev/null # -> .sshrc

. .sshrc
~/bin/ssh-agent.sh > /dev/null
. ~/.sshrc
10 changes: 4 additions & 6 deletions xsession
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,14 @@ fi
if [ "${HOST}" = 'spof' ];then
show-pceol
askXrandr
SSHAGENTRC="$(ssh-agent -c)"
xsetroot -solid gray &
xscreensaver -nosplash &
~/dotfiles/bin/xclock.sh
xset b off
~/dotfiles/bin/Xkeyboard.sh
fi

if [ "${HOST}" = 'tempof' ];then
SSHAGENTRC="$(ssh-agent -s)"
if [ "${HOST}" = 'tempo' ];then
xsetroot -solid black &
xscreensaver -nosplash &
~/dotfiles/bin/xclock.sh
Expand All @@ -79,7 +77,6 @@ if [ "${HOST}" = 'tempof' ];then
fi

if [ "${HOST}" = 'ljb' ];then
SSHAGENTRC="$(ssh-agent -c)"
xsetroot -solid gray &
xscreensaver -nosplash &
xset b off
Expand All @@ -94,8 +91,9 @@ if [ "${HOST}" = 'tiptop' ];then
~/dotfiles/bin/xclock.sh
~/dotfiles/bin/Xkeyboard.sh
fi
echo ${SSHAGENTRC} > ~/.ssh-agent.sh
eval ${SSHAGENTRC}

~/bin/ssh-agent.sh
. ~/.sshrc

openbox

0 comments on commit 8be7c03

Please sign in to comment.