termux-packages/packages/openssh/source-ssh-agent.sh
Leonid Pliushch 92534de10f openssh: source-ssh-agent should put socket in $PREFIX/var/run
/tmp is being wiped on application restart.
2020-04-14 17:11:33 +03:00

20 lines
556 B
Bash

#!/bin/sh
# source-ssh-agent: Script to source for ssh-agent to work.
export SSH_AUTH_SOCK=$PREFIX/var/run/ssh-agent
start_agent() {
rm -f $SSH_AUTH_SOCK
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add
}
MESSAGE=$(ssh-add -L 2>&1)
if [ "$MESSAGE" = 'Could not open a connection to your authentication agent.' -o \
"$MESSAGE" = 'Error connecting to agent: Connection refused' -o \
"$MESSAGE" = 'Error connecting to agent: No such file or directory' ]; then
start_agent
elif [ "$MESSAGE" = "The agent has no identities." ]; then
ssh-add
fi