aboutsummaryrefslogtreecommitdiff
path: root/ssh-agent-eval
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2014-09-18 16:38:16 -0300
committerSilvio Rhatto <user@example.org>2014-09-18 16:38:16 -0300
commit86f3fe6a9809103ed613a6d889a9ec4756887cc1 (patch)
tree6add951131060b123d2265d65c339cda853c128e /ssh-agent-eval
downloadutils-ssh-86f3fe6a9809103ed613a6d889a9ec4756887cc1.tar.gz
utils-ssh-86f3fe6a9809103ed613a6d889a9ec4756887cc1.tar.bz2
Initial import
Diffstat (limited to 'ssh-agent-eval')
-rwxr-xr-xssh-agent-eval46
1 files changed, 46 insertions, 0 deletions
diff --git a/ssh-agent-eval b/ssh-agent-eval
new file mode 100755
index 0000000..2edf711
--- /dev/null
+++ b/ssh-agent-eval
@@ -0,0 +1,46 @@
+#!/bin/bash
+#
+# Initializes the ssh-agent
+#
+
+# SSH Agent
+#SSHAGENT=/usr/bin/ssh-agent
+#SSHAGENTARGS="-s"
+#
+#function ssh_agent_eval_run {
+# eval `$SSHAGENT $SSHAGENTARGS` &> /dev/null
+# trap "ps $SSH_AGENT_PID &> /dev/null && kill $SSH_AGENT_PID" 0
+#}
+#
+#if [ "$1" == "-f" ]; then
+# echo "Starting a new ssh-agent..."
+# ssh_agent_eval_run
+#elif [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then
+# ssh_agent_eval_run
+#fi
+
+# See http://mah.everybody.org/docs/ssh
+
+SSH_ENV="$HOME/.ssh/environment"
+
+function start_agent {
+ echo "Initialising new SSH agent..."
+ /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
+ echo succeeded
+ chmod 600 "${SSH_ENV}"
+ . "${SSH_ENV}" > /dev/null
+ /usr/bin/ssh-add;
+ /usr/bin/monkeysphere subkey-to-ssh-agent
+}
+
+# Source SSH settings, if applicable
+
+if [ -f "${SSH_ENV}" ]; then
+ . "${SSH_ENV}" > /dev/null
+ #ps ${SSH_AGENT_PID} doesn't work under cywgin
+ ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
+ start_agent;
+ }
+else
+ start_agent;
+fi