.config/sagent
2026-01-16 16:11:17 -05:00

47 lines
799 B
Bash
Executable File

#!/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)