From 461d03a73063d29110a2fdc37bae04811122c81e Mon Sep 17 00:00:00 2001 From: Joel Beckmeyer Date: Tue, 20 Oct 2026 14:49:30 -0400 Subject: [PATCH] add termux ssh-agent alternative path --- dot_config/zsh/dot_zshrc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/dot_config/zsh/dot_zshrc b/dot_config/zsh/dot_zshrc index ebe7fd4..d5d5331 100644 --- a/dot_config/zsh/dot_zshrc +++ b/dot_config/zsh/dot_zshrc @@ -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