diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2019-01-05 10:29:04 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2019-01-05 10:29:04 -0200 |
commit | 78172a1aa1f3da0336f8152da2d9265bb59dc933 (patch) | |
tree | 2a2cd3a757e37c9d2ed17db013c1731071b8d666 /ssh-keygen-wrapper | |
parent | d6cc496425b2e7386a2702a35bd2a5a84d1fd24b (diff) | |
download | utils-ssh-78172a1aa1f3da0336f8152da2d9265bb59dc933.tar.gz utils-ssh-78172a1aa1f3da0336f8152da2d9265bb59dc933.tar.bz2 |
Adds ssh-keygen-wrapper
Diffstat (limited to 'ssh-keygen-wrapper')
-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" |