ignorance09
1/11/2017 - 3:12 PM

ipsec-gen

#!/bin/bash

function gen {
  dd if=/dev/urandom bs=1 count=10000 2>/dev/null | tr -dc a-f0-9 | fold -w $1 | sed 's/^/0x/' | head -n 1
}

spi=`gen 8`
reqid=`gen 8`
auth_key=`gen 64`
enc_key=`gen 64`

cat << EOF
ENDPOINT=$1
SPI=$spi
REQID=$reqid
AUTH_KEY=$auth_key
ENC_KEY=$enc_key
EOF