add termux ssh-agent alternative path
This commit is contained in:
1 parent
d3d7d8636b
commit
461d03a730
1 file changed
+20
@@ -102,6 +102,26 @@ if command -v keychain >/dev/null; then
|
||||
else
|
||||
ssh-add ~/.ssh/id_rsa
|
||||
fi
|
||||
elif [ -n "$TERMUX_VERSION" ]; then
|
||||
# No keychain/rbw on Termux. Keep a persistent ssh-agent across sessions
|
||||
# (same idea as keychain above) and prompt for the passphrase right here at
|
||||
# shell start instead of waiting for the first `ssh` invocation. To unlock,
|
||||
# long-press the terminal at the "Enter passphrase" prompt below and choose
|
||||
# "Autofill password" to pull it from Bitwarden.
|
||||
termux_ssh_agent_env="$XDG_STATE_HOME/ssh/agent-env"
|
||||
mkdir -p "$(dirname "$termux_ssh_agent_env")"
|
||||
if [ -z "$SSH_AUTH_SOCK" ] && [ -f "$termux_ssh_agent_env" ]; then
|
||||
. "$termux_ssh_agent_env" >/dev/null
|
||||
kill -0 "$SSH_AGENT_PID" 2>/dev/null || unset SSH_AGENT_PID SSH_AUTH_SOCK
|
||||
fi
|
||||
if [ -z "$SSH_AGENT_PID" ]; then
|
||||
ssh-agent -s > "$termux_ssh_agent_env"
|
||||
. "$termux_ssh_agent_env" >/dev/null
|
||||
fi
|
||||
# Only prompts if the agent doesn't already have a key loaded (e.g. from an
|
||||
# earlier session in this same Termux app lifetime).
|
||||
ssh-add -l >/dev/null 2>&1 || ssh-add ~/.ssh/id_rsa
|
||||
unset termux_ssh_agent_env
|
||||
fi
|
||||
|
||||
# Command not found handler
|
||||
|
||||
Reference in new issue
Block a user