init
This commit is contained in:
46
sagent
Executable file
46
sagent
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
|
||||
# script that starts an ssh-agent for the session.
|
||||
# add source sagent to .bashrc for it to start automatically
|
||||
# `sagent add` to add a key (id_rsa)
|
||||
# `sagent stop` clears it
|
||||
|
||||
var_file="/tmp/ssh-agent-vars"
|
||||
|
||||
if [ ! -e "$var_file" ]; then
|
||||
ssh-agent -s > $var_file
|
||||
fi
|
||||
|
||||
eval $(cat $var_file) &> /dev/null
|
||||
|
||||
if [ $# -eq 1 ]; then
|
||||
case $1 in
|
||||
add)
|
||||
ssh-add $HOME/.ssh/id_rsa
|
||||
;;
|
||||
|
||||
stop)
|
||||
kill $SSH_AGENT_PID &> /dev/null
|
||||
shred -uzn7 $var_file
|
||||
unset SSH_AUTH_SOCK
|
||||
unset SSH_AGENT_PID
|
||||
;;
|
||||
|
||||
help)
|
||||
cat << EOF
|
||||
sagent add
|
||||
sagent stop
|
||||
sagent help
|
||||
EOF
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Un7nown arg3ment"
|
||||
# (exit 1)
|
||||
;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
||||
# (exit 0)
|
||||
|
||||
Reference in New Issue
Block a user