diff options
-rwxr-xr-x | ssh-keygen-wrapper | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/ssh-keygen-wrapper b/ssh-keygen-wrapper new file mode 100755 index 0000000..9e6fd1a --- /dev/null +++ b/ssh-keygen-wrapper @@ -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" |