]> gitweb.fluxo.info Git - utils-ssh.git/commitdiff
Adds ssh-keygen-wrapper
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 5 Jan 2019 12:29:04 +0000 (10:29 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 5 Jan 2019 12:29:04 +0000 (10:29 -0200)
ssh-keygen-wrapper [new file with mode: 0755]

diff --git a/ssh-keygen-wrapper b/ssh-keygen-wrapper
new file mode 100755 (executable)
index 0000000..9e6fd1a
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+# Create a new SSH keypair.
+#
+
+# Parameters
+BASENAME="`basename $0`"
+TYPE="$1"
+HANDLE="$2"
+OPTS=""
+
+# Check
+if [ -z "$HANDLE" ]; then
+  echo "usage: $BASENAME <keytype> <handle>"
+  echo "resulting key is stored at ~/.ssh/keys/<keytype>/<handle>"
+  exit 1
+elif [ -e "$HOME/.ssh/keys/$TYPE/$HANDLE" ]; then
+  echo "$BASENAME: file already exists: $HOME/.ssh/keys/$TYPE/$HANDLE"
+  exit 1
+fi
+
+# Handle custom options
+if [ "$TYPE" == "rsa" ]; then
+  OPTS="-b 4096"
+fi
+
+# Dispatch
+ssh-keygen -t $TYPE $OPTS -f $HOME/.ssh/keys/$TYPE/$HANDLE -C "$HANDLE"