penguin/utils

my env utils

commit e538bf76f33da14af2b58716fb107496cff4dc9a

author斟酌 鵬兄 <tgckpg@gmail.com>
date2026-06-27T09:42:56Z
subjectHandle ssh agent
commit e538bf76f33da14af2b58716fb107496cff4dc9a
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2026-06-27T09:42:56Z

    Handle ssh agent
---
 bash/sources/15_gpg-agent | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/bash/sources/15_gpg-agent b/bash/sources/15_gpg-agent
index 958d09d..181759d 100644
--- a/bash/sources/15_gpg-agent
+++ b/bash/sources/15_gpg-agent
@@ -1,5 +1,27 @@
 #!/bin/bash
 
+function _rbash_enable_gpg_ssh_support {
+	local _gnupg_home _conf
+
+	_gnupg_home="${GNUPGHOME:-$HOME/.gnupg}"
+	_conf="$_gnupg_home/gpg-agent.conf"
+
+	mkdir -p "$_gnupg_home" || return 1
+	chmod 700 "$_gnupg_home" 2>/dev/null || true
+
+	touch "$_conf" || return 1
+	chmod 600 "$_conf" 2>/dev/null || true
+
+	if ! grep -Eq '^[[:space:]]*enable-ssh-support([[:space:]]|$)' "$_conf"; then
+		printf "\n%s\n" "enable-ssh-support" >> "$_conf"
+	fi
+
+	gpgconf --kill gpg-agent >/dev/null 2>&1 || true
+	gpg-connect-agent /bye >/dev/null 2>&1 || true
+}
+
+_rbash_enable_gpg_ssh_support
+
 if command -v gpg-connect-agent >/dev/null 2>&1; then
 	export GPG_TTY
 	GPG_TTY="$(tty 2>/dev/null || true)"