Skip to content

Instantly share code, notes, and snippets.

@nathando
Created April 12, 2017 10:11
Show Gist options
  • Select an option

  • Save nathando/0998e7224d59cbe706143155cd6422c9 to your computer and use it in GitHub Desktop.

Select an option

Save nathando/0998e7224d59cbe706143155cd6422c9 to your computer and use it in GitHub Desktop.
Generate and copy client certs from OpenVPN server
#!/bin/bash
server="xxx.xxx.xxx.xxx"
client=$1
ssh root@$server client=$client 'bash -s' <<'ENDSSH'
cd /etc/openvpn/easy-rsa
. ./vars
./build-key --batch $client
ENDSSH
scp root@$server:/etc/openvpn/easy-rsa/keys/$client.crt .
scp root@$server:/etc/openvpn/easy-rsa/keys/$client.key .
scp root@$server:/etc/openvpn/easy-rsa/keys/client.ovpn ./$client.ovpn
scp root@$server:/etc/openvpn/ca.crt .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment