blob: b9f9cbb582166aa2c89e6dace323a75a7c798d55 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!/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
# Ensure destination folder exists
mkdir -p $HOME/.ssh/keys/$TYPE
# Dispatch
ssh-keygen -t $TYPE $OPTS -f $HOME/.ssh/keys/$TYPE/$HANDLE -C "$HANDLE"
|