Skip to content

Commit 5f060c0

Browse files
committed
save ssh keys
1 parent bb6164c commit 5f060c0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

after-install.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
set -e
66

7+
# Backup our ssh keys if they aren't already.
8+
if [ -d "/share/workers/defaults/ssh" ] && [ ! -d "/share/workers/defaults/ssh/$(hostname -s)" ]; then
9+
mkdir "/share/workers/defaults/ssh/$(hostname -s)"
10+
cp -r /etc/ssh/ssh_host_* "/share/workers/defaults/ssh/$(hostname -s)"
11+
fi
12+
713
if [ -d ~abc/.ssh ]; then
814
chown -R abc: ~abc
915
fi
@@ -15,3 +21,11 @@ if [ -x "/bin/systemctl" ]; then
1521
/bin/systemctl restart supervisor
1622
fi
1723
fi
24+
25+
# Replace the ssh keys with the backup if they're different; then restart sshd.
26+
if [ -d "/share/workers/defaults/ssh/$(hostname -s)" ] && \
27+
! diff -q "/share/workers/defaults/ssh/$(hostname -s)/ssh_host_ecdsa_key" /etc/ssh/ssh_host_ecdsa_key >/dev/null 2>&1
28+
then
29+
cp -r "/share/workers/defaults/ssh/$(hostname -s)/ssh_host_*" /etc/ssh/
30+
/bin/systemctl restart sshd
31+
fi

0 commit comments

Comments
 (0)