console: ssh-agent for termux
Some checks failed
Update Site / trigger_update (push) Has been cancelled

This commit is contained in:
Pavel Korytov 2025-03-06 10:56:35 +03:00
parent 8264a067e9
commit b7728cf9ca
2 changed files with 18 additions and 4 deletions

View file

@ -51,11 +51,18 @@ fi
# SSL Certs:1 ends here # SSL Certs:1 ends here
# [[file:Console.org::*ssh-agent][ssh-agent:1]] # [[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 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 fi
if [[ ! -f "$SSH_AUTH_SOCK" ]]; then if [[ ! -f "$SSH_AUTH_SOCK" ]]; then
source "/tmp/ssh-agent.env" >/dev/null source "$SSH_AGENT_DIR/ssh-agent.env" >/dev/null
fi fi
# ssh-agent:1 ends here # ssh-agent:1 ends here

View file

@ -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]]: Got the idea for below from [[https://wiki.archlinux.org/title/SSH_keys#SSH_agents][ArchWiki]]:
#+begin_src bash #+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 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 fi
if [[ ! -f "$SSH_AUTH_SOCK" ]]; then 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 fi
#+end_src #+end_src
** Guix settings ** Guix settings