ssh-agent: fix non-existing .ssh folder
parent
f2300b1ce3
commit
304928d2bc
5
.profile
5
.profile
|
@ -98,14 +98,17 @@ command -v dwb >/dev/null && export BROWSER="dwb"
|
|||
## SSH-Agent
|
||||
## WARNING: this is somewhat insecure if someone else has root access to the machine.
|
||||
if command -v ssh-agent >/dev/null; then
|
||||
[ ! -e "$HOME/.ssh" ] && mkdir -p "$HOME/.ssh"
|
||||
if [ -d "$HOME/.ssh" ]; then
|
||||
readonly SSH_ENV_FILE="$HOME/.ssh/ssh-agent-env"
|
||||
if [ ! -f "$SSH_ENV_FILE" ]; then
|
||||
ssh-agent > "$SSH_ENV_FILE"
|
||||
fi
|
||||
source "$SSH_ENV_FILE"
|
||||
fi
|
||||
fi
|
||||
## Kill ssh-agent if this is the only running session.
|
||||
trap '[ $(w -hs $USER | wc -l) -eq 1 ] && test -n "$SSH_AGENT_PID" && eval $(ssh-agent -k) && rm "$SSH_ENV_FILE"' 0
|
||||
trap '[ $(w -hs $USER | wc -l) -eq 1 ] && test -n "$SSH_AGENT_PID" && eval $(ssh-agent -k) && rm -f "$SSH_ENV_FILE"' 0
|
||||
|
||||
## Set TEMP dir if you want to override /tmp for some applications that check
|
||||
## for this variable. Usually not a good idea.
|
||||
|
|
Loading…
Reference in New Issue