From 8be7c03d320336217ee83311d71643b7152c01cb Mon Sep 17 00:00:00 2001 From: Mikko Lehto Date: Sun, 23 Sep 2018 15:13:21 +0300 Subject: [PATCH] re-do ssh-agent invokation --- bin/ssh-agent.sh | 34 ++++++++++++++++++++++++++++++++++ shrc | 5 ++--- xsession | 10 ++++------ 3 files changed, 40 insertions(+), 9 deletions(-) create mode 100755 bin/ssh-agent.sh diff --git a/bin/ssh-agent.sh b/bin/ssh-agent.sh new file mode 100755 index 0000000..936299f --- /dev/null +++ b/bin/ssh-agent.sh @@ -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 diff --git a/shrc b/shrc index 405102c..c56e610 100644 --- a/shrc +++ b/shrc @@ -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 diff --git a/xsession b/xsession index 2440406..87272d4 100755 --- a/xsession +++ b/xsession @@ -61,7 +61,6 @@ fi if [ "${HOST}" = 'spof' ];then show-pceol askXrandr - SSHAGENTRC="$(ssh-agent -c)" xsetroot -solid gray & xscreensaver -nosplash & ~/dotfiles/bin/xclock.sh @@ -69,8 +68,7 @@ if [ "${HOST}" = 'spof' ];then ~/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 @@ -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 @@ -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