Skip to content

Instantly share code, notes, and snippets.

@renatolfc
Created December 28, 2014 18:50
Show Gist options
  • Save renatolfc/18e428b5a758df24455b to your computer and use it in GitHub Desktop.
Save renatolfc/18e428b5a758df24455b to your computer and use it in GitHub Desktop.
Script to generate an OpenVPN client configuration file in the unified format
#!/bin/sh
##
## Usage: ./ovpn-writer.sh SERVER CA_CERT CLIENT_CERT CLIENT_KEY SHARED_SECRET > client.ovpn
##
server=${1?"The server address is required"}
cacert=${2?"The path to the ca certificate file is required"}
client_cert=${3?"The path to the client certificate file is required"}
client_key=${4?"The path to the client private key file is required"}
tls_key=${5?"The path to the TLS shared secret file is required"}
cat << EOF
client
dev tun
remote ${server}
resolv-retry infinite
nobind
persist-key
persist-tun
ca [inline]
cert [inline]
key [inline]
tls-auth [inline] 1
verb 1
keepalive 10 120
port 1194
proto udp
cipher BF-CBC
comp-lzo
remote-cert-tls server
<ca>
EOF
cat ${cacert}
cat << EOF
</ca>
<cert>
EOF
cat ${client_cert}
cat << EOF
</cert>
<key>
EOF
cat ${client_key}
cat << EOF
</key>
<tls-auth>
EOF
cat ${tls_key}
cat << EOF
</tls-auth>
EOF
@thoschworks
Copy link

EDIT: See my fork which seems to be working on iOS 9.3.3.

@graysky2: Cannot find your fork.

@HarshalRathore
Copy link

HarshalRathore commented Sep 8, 2021

I successfully created the client.ovpn file then ran this command openvpn3 session-start --config <absolute_path_to_client.ovpn> then it gave me this error config-import: ** ERROR ** ERR_PROFILE_GENERIC: [inline], [inline], [inline], [inline] what am i doing wrong please help me..

@renatolfc
Copy link
Author

I successfully created the client.ovpn file then ran this command openvpn3 session-start --config <absolute_path_to_client.ovpn> then it gave me this error config-import: ** ERROR ** ERR_PROFILE_GENERIC: [inline], [inline], [inline], [inline] what am i doing wrong please help me..

Check https://gist.github.com/renatolfc/18e428b5a758df24455b#gistcomment-1764360. Syntax might have changed. You might be able to get away with removing the lines with [inline].

@HarshalRathore
Copy link

HarshalRathore commented Sep 9, 2021

I successfully created the client.ovpn file then ran this command openvpn3 session-start --config <absolute_path_to_client.ovpn> then it gave me this error config-import: ** ERROR ** ERR_PROFILE_GENERIC: [inline], [inline], [inline], [inline] what am i doing wrong please help me..

Check https://gist.github.com/renatolfc/18e428b5a758df24455b#gistcomment-1764360. Syntax might have changed. You might be able to get away with removing the lines with [inline].

can you please provide the modified code file for this I tried to remove those [inline] thingy but it is still not working . any help will be appreciated thankx.
BTW I am using ubuntu 21.04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment