aboutsummaryrefslogtreecommitdiff
path: root/ssh-agent-keychain
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2024-08-09 10:13:00 -0300
committerSilvio Rhatto <rhatto@riseup.net>2024-08-09 10:13:00 -0300
commitec3f752bc2ce9aa054009b5701cf731dbd082843 (patch)
tree088c46e9556e5965ea9e612f57d9c3b71f8351a8 /ssh-agent-keychain
parentbfd0ff5979052ecb4556264641235e32d04834be (diff)
downloadutils-ssh-master.tar.gz
utils-ssh-master.tar.bz2
Fix: rename ssh-agent-loadkeys as ssh-agent-keychain; update ssh-agent-evalHEADmaster
Diffstat (limited to 'ssh-agent-keychain')
-rwxr-xr-xssh-agent-keychain56
1 files changed, 56 insertions, 0 deletions
diff --git a/ssh-agent-keychain b/ssh-agent-keychain
new file mode 100755
index 0000000..0083283
--- /dev/null
+++ b/ssh-agent-keychain
@@ -0,0 +1,56 @@
+#!/bin/sh
+#
+# Manage ssh-agent with Keychain:
+#
+# * https://www.funtoo.org/Funtoo:Keychain
+# * https://wiki.archlinux.org/title/SSH_keys#Keychain
+#
+
+# Check for keychain
+if [ -x '/usr/bin/keychain' ]; then
+ mkdir -p $HOME/.keychain
+
+ if [ -z "$FQDN" ]; then
+ FQDN="`cat /etc/hostname`"
+ fi
+
+ # Setup keychain
+ /usr/bin/keychain -q --noask
+
+ if [ -e "$HOME/.keychain/$FQDN-sh" ]; then
+ . $HOME/.keychain/$FQDN-sh
+ fi
+
+ # Load gpg-agent info
+ #if [ -e "$HOME/.keychain/$HOSTNAME-sh-gpg" ]; then
+ # . $HOME/.keychain/$HOSTNAME-sh-gpg
+ #fi
+
+ # Check for monkeysphere
+ if [ -x '/usr/bin/monkeysphere' ]; then
+ #if ! ssh-add -l &> /dev/null && [ "`gpg --list-secret-keys | wc -l`" != "0" ]; then
+ # From MONKEYSPHERE(1): "The MONKEYSPHERE_SUBKEYS_FOR_AGENT environment can be used to specify the full
+ # fingerprints of specific keys to add to the agent (space separated), instead
+ # of adding them all."
+ if [ ! -z "$MONKEYSPHERE_SUBKEYS_FOR_AGENT" ]; then
+ monkeysphere subkey-to-ssh-agent
+ fi
+ fi
+
+ # Check for RSA key
+ #if [ -e "$HOME/.ssh/id_rsa" ]; then
+ # /usr/bin/keychain -q $HOME/.ssh/id_rsa
+ #fi
+
+ # Check for ED25519 key
+ #if [ -e "$HOME/.ssh/id_ed25519" ]; then
+ # /usr/bin/keychain -q $HOME/.ssh/id_ed25519
+ #fi
+
+ # Autoload keys
+ if [ -d "$HOME/.ssh/autoload" ]; then
+ for key in `ls $HOME/.ssh/autoload`; do
+ /usr/bin/keychain -q $HOME/.ssh/autoload/$key
+ done
+ fi
+fi