3 # Usage: astgenkey [ -q ] [ -n ] [keyname]
6 if [ "$1" = "-q" ]; then
8 if [ "$2" = "-n" ]; then
14 elif [ "$1" = "-n" ]; then
16 if [ "$2" = "-q" ]; then
26 if [ "$QUIET" != 'y' ]; then
28 echo "This script generates an RSA private and public key pair"
29 echo "in PEM format for use by Asterisk. You will be asked to"
30 echo "enter a passcode for your key multiple times. Please"
31 echo "enter the same code each time. The resulting files will"
32 echo "need to be moved to /var/lib/asterisk/keys if you want"
33 echo "to use them, and any private keys (.key files) will"
34 echo "need to be initialized at runtime either by running"
35 echo "Asterisk with the '-i' option, or with the 'init keys'"
36 echo "command once Asterisk is running."
38 echo "Press ENTER to continue or ^C to cancel."
42 while [ "$KEY" = "" ]; do
43 echo -n "Enter key name: "
47 rm -f ${KEY}.key ${KEY}.pub
49 echo "Generating SSL key '$KEY': "
50 openssl genrsa -out ${KEY}.key ${DES3} 1024
51 openssl rsa -in ${KEY}.key -pubout -out ${KEY}.pub
53 if [ -f "${KEY}.key" ] && [ -f "${KEY}.pub" ]; then
54 if [ "$QUIET" != 'y' ]; then
55 echo "Key creation successful."
56 echo "Public key: ${KEY}.pub"
57 echo "Private key: ${KEY}.key"
60 echo "Unknown error creating keys."