]> ruderich.org/simon Gitweb - safcm/safcm.git/blobdiff - cmd/safcm/testdata/ssh/prepare.sh
tests: add very basic end-to-end test with real ssh server
[safcm/safcm.git] / cmd / safcm / testdata / ssh / prepare.sh
diff --git a/cmd/safcm/testdata/ssh/prepare.sh b/cmd/safcm/testdata/ssh/prepare.sh
new file mode 100755 (executable)
index 0000000..6608a3a
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+# Create files for SSH server
+
+set -eu
+
+
+cd "$(dirname "$0")"
+
+# Generate new keys so nobody else can login as this user. Host keys would be
+# safe to commit but lets not needlessly commit private keys anyway.
+if ! test -e sshd/ssh_host_key; then
+    ssh-keygen -q -t ed25519 -N '' -f sshd/ssh_host_key
+fi
+if ! test -e ssh/id_ed25519; then
+    ssh-keygen -q -t ed25519 -N '' -f ssh/id_ed25519
+fi
+if ! test -e ssh/authorized_keys; then
+    cat ssh/id_ed25519.pub > ssh/authorized_keys
+fi
+if ! test -e ssh/known_hosts; then
+    printf '[127.0.0.1]:29327 ' > ssh/known_hosts
+    cat sshd/ssh_host_key.pub >> ssh/known_hosts
+fi