home · contact · privacy
Script to ease setting up SSH connections.
authorChristian Heller <c.heller@plomlompom.de>
Sat, 15 Dec 2018 11:04:11 +0000 (12:04 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sat, 15 Dec 2018 11:04:11 +0000 (12:04 +0100)
all_new_2018/prepare_to_meet_server.sh [new file with mode: 0644]

diff --git a/all_new_2018/prepare_to_meet_server.sh b/all_new_2018/prepare_to_meet_server.sh
new file mode 100644 (file)
index 0000000..1e73ae0
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+# Do some of the steps necessary to SSH (key-based) with another server.
+set -e
+
+target="$1"
+
+# We need a public key to copy over, so generate it if not found.
+if [ ! -f ~/.ssh/id_rsa.pub ]; then
+    ssh-keygen
+fi
+
+# Add target to ~/.ssh/known_hosts so we don't get
+# asked for permission at inopportune moments.
+ssh-keyscan -H "$target"
+
+# Tell user what to do.
+echo "APPEND FOLLOWING TO TARGET'S ~/.ssh/authorized_keys:"
+cat ~/.ssh/id_rsa.pub