From b7728cf9cae793c72858db9e2827a8226289066a Mon Sep 17 00:00:00 2001 From: SqrtMinusOne Date: Thu, 6 Mar 2025 10:56:35 +0300 Subject: [PATCH] console: ssh-agent for termux --- .profile | 11 +++++++++-- Console.org | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.profile b/.profile index 6de1f06..4389b3d 100755 --- a/.profile +++ b/.profile @@ -51,11 +51,18 @@ fi # SSL Certs:1 ends here # [[file:Console.org::*ssh-agent][ssh-agent:1]] +SSH_AGENT_DIR="/tmp" + +if [ "$IS_ANDROID" == "true" ]; then + SSH_AGENT_DIR="/data/data/com.termux/files/tmp" + mkdir -p $SSH_AGENT_DIR +fi + if ! pgrep -u "$USER" ssh-agent > /dev/null; then - ssh-agent -t 1h > "/tmp/ssh-agent.env" + ssh-agent -t 1h > "$SSH_AGENT_DIR/ssh-agent.env" fi if [[ ! -f "$SSH_AUTH_SOCK" ]]; then - source "/tmp/ssh-agent.env" >/dev/null + source "$SSH_AGENT_DIR/ssh-agent.env" >/dev/null fi # ssh-agent:1 ends here diff --git a/Console.org b/Console.org index 020ddcd..5f4210a 100644 --- a/Console.org +++ b/Console.org @@ -109,11 +109,18 @@ I'm paranoid so I encrypt my SSH keys. Got the idea for below from [[https://wiki.archlinux.org/title/SSH_keys#SSH_agents][ArchWiki]]: #+begin_src bash +SSH_AGENT_DIR="/tmp" + +if [ "$IS_ANDROID" == "true" ]; then + SSH_AGENT_DIR="/data/data/com.termux/files/tmp" + mkdir -p $SSH_AGENT_DIR +fi + if ! pgrep -u "$USER" ssh-agent > /dev/null; then - ssh-agent -t 1h > "$XDG_RUNTIME_DIR/ssh-agent.env" + ssh-agent -t 1h > "$SSH_AGENT_DIR/ssh-agent.env" fi if [[ ! -f "$SSH_AUTH_SOCK" ]]; then - source "$XDG_RUNTIME_DIR/ssh-agent.env" >/dev/null + source "$SSH_AGENT_DIR/ssh-agent.env" >/dev/null fi #+end_src ** Guix settings