summaryrefslogtreecommitdiff
path: root/gemfeed/examples/conf/frontends/scripts/dserver-update-key-cache.sh.tpl
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-10-02 11:28:55 +0300
committerPaul Buetow <paul@buetow.org>2025-10-02 11:28:55 +0300
commit2b034797107660d4d83f8a7acdc55d32db785b82 (patch)
tree522fb586193c8a65ca6aee42df64eecc3555f644 /gemfeed/examples/conf/frontends/scripts/dserver-update-key-cache.sh.tpl
parent4d7d90638186ac71067232007607f6637d560a4d (diff)
Update content for md
Diffstat (limited to 'gemfeed/examples/conf/frontends/scripts/dserver-update-key-cache.sh.tpl')
-rw-r--r--gemfeed/examples/conf/frontends/scripts/dserver-update-key-cache.sh.tpl34
1 files changed, 34 insertions, 0 deletions
diff --git a/gemfeed/examples/conf/frontends/scripts/dserver-update-key-cache.sh.tpl b/gemfeed/examples/conf/frontends/scripts/dserver-update-key-cache.sh.tpl
new file mode 100644
index 00000000..86b5ecf9
--- /dev/null
+++ b/gemfeed/examples/conf/frontends/scripts/dserver-update-key-cache.sh.tpl
@@ -0,0 +1,34 @@
+#!/bin/ksh
+
+CACHEDIR=/var/run/dserver/cache
+DSERVER_USER=_dserver
+DSERVER_GROUP=_dserver
+
+echo 'Updating SSH key cache'
+
+ls /home/ | while read remoteuser; do
+ keysfile=/home/$remoteuser/.ssh/authorized_keys
+
+ if [ -f $keysfile ]; then
+ cachefile=$CACHEDIR/$remoteuser.authorized_keys
+ echo "Caching $keysfile -> $cachefile"
+
+ cp $keysfile $cachefile
+ chown $DSERVER_USER:$DSERVER_GROUP $cachefile
+ chmod 600 $cachefile
+ fi
+done
+
+# Cleanup obsolete public SSH keys
+find $CACHEDIR -name \*.authorized_keys -type f |
+while read cachefile; do
+ remoteuser=$(basename $cachefile | cut -d. -f1)
+ keysfile=/home/$remoteuser/.ssh/authorized_keys
+
+ if [ ! -f $keysfile ]; then
+ echo 'Deleting obsolete cache file $cachefile'
+ rm $cachefile
+ fi
+done
+
+echo 'All set...'