{"id":18,"date":"2014-10-26T13:47:15","date_gmt":"2014-10-26T11:47:15","guid":{"rendered":"https:\/\/serverstuff.info\/wordpress\/?p=18"},"modified":"2014-10-26T13:59:53","modified_gmt":"2014-10-26T11:59:53","slug":"openvpn-setup-with-mysql-auth-and-ssl-port-sharing","status":"publish","type":"post","link":"https:\/\/serverstuff.info\/wordpress\/2014\/10\/26\/openvpn-setup-with-mysql-auth-and-ssl-port-sharing\/","title":{"rendered":"OpenVPN setup with mysql auth and ssl port sharing"},"content":{"rendered":"<p>So, I decided it was time to prevent some firewalls from blocking my connection to openvpn.<br \/>\nHere&#8217;s what I did to share port 443 ( which I already had an apache listening on ) with openvpn !<\/p>\n<pre language=\"bash\">\r\n# Make apache Listen on port 4545 and replace all VirtualHost directives to use that.\r\nemerge net-misc\/openvpn app-crypt\/easy-rsa sys-auth\/pam_mysql\r\ncp -prv \/usr\/share\/easy-rsa ~\r\ncd ~\/easy-rsa\r\ncp vars{,.orig}\r\ncat &gt;&gt; vars &lt;&lt; _EOF_\r\nexport EASY_RSA=\"`pwd`\"\r\nexport KEY_DIR=\"$EASY_RSA\/keys\"\r\nexport OPENSSL=\"openssl\"\r\nexport PKCS11TOOL=\"pkcs11-tool\"\r\nexport GREP=\"grep\"\r\nexport KEY_CONFIG=`$EASY_RSA\/whichopensslcnf $EASY_RSA`\r\nexport KEY_SIZE=4096\r\nexport CA_EXPIRE=3650\r\nexport KEY_EXPIRE=3650\r\nexport KEY_COUNTRY=\"US\"\r\nexport KEY_PROVINCE=\"FL\"\r\nexport KEY_CITY=\"Miami\"\r\nexport KEY_ORG=\"Fort-Funston\"\r\nexport KEY_EMAIL=\"master@myhost.domain\"\r\nexport KEY_CN=changeme # Common Name (eg, your name or your server's hostname) \r\nexport KEY_NAME=changeme # Name\r\nexport KEY_OU=changeme # Organizational Unit Name (eg, section)\r\n_EOF_\r\nsource .\/vars\r\n.\/clean_all\r\n.\/build-ca\r\n.\/build-key-server server\r\n.\/build-dh\r\nopenvpn --genkey --secret \/root\/easy-rsa\/keys\/ta.key\r\nmkdir -p \/etc\/openvpn\/certs\r\ncp -pv ~\/easy-rsa\/keys\/{ca.crt,ca.key,server.crt,server.key,ta.key,dh4096.pem} \/etc\/openvpn\/certs\/\r\n\r\ncat &gt;&gt; \/etc\/openvpn\/openvpn.conf &lt;&lt; _EOF_\r\ndev tun\r\n# use udp .. it performs alot better, this tutorial just uses tcp because it is sharing the port with apache !\r\nproto tcp\r\nlocal 203.0.113.10 # replace with the ip you want it listening instead of 0.0.0.0\r\nport 443\r\nport-share 127.0.0.1 4545\r\nkeepalive 10 120\r\ncomp-lzo\r\nuser nobody\r\ngroup nobody\r\nserver 192.168.7.0 255.255.255.0\r\nca \/etc\/openvpn\/certs\/ca.crt\r\ncert \/etc\/openvpn\/certs\/server.crt\r\nkey \/etc\/openvpn\/certs\/server.key\r\ndh \/etc\/openvpn\/certs\/dh2048.pem\r\ntls-auth \/etc\/openvpn\/certs\/ta.key\r\n#tls-cipher DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-CAMELLIA256-SHA:DHE-RSA-AES256-SHA:DHE-RSA-CAMELLIA128-SHA:DHE-RSA-AES128-SHA:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA # bettercrypto.org\r\ntls-version-min 1.2 # you can try use tls-cipher see if everything is ok for you, if not, try this.\r\ncipher AES-256-CBC\r\nauth SHA384\r\nverb 5\r\n_EOF_\r\n\r\nsed -i 's\/net.ipv4.ip_forward = 0\/net.ipv4.ip_forward = 1\/' \/etc\/sysctl.conf\r\nsysctl -p\r\nrc-update add openvpn default\r\n\/etc\/init.d\/apache2 restart\r\n\/etc\/init.d\/openvpn restart\r\n\r\n# now for the client part, give him this one file\r\n.\/build-key-pass client\r\ncat &gt;&gt; ~\/client.ovpn &lt;&lt; _EOF_\r\nclient\r\nremote 203.0.113.10\r\ndev tun\r\n# set udp here too if you decided to use that!\r\nproto tcp\r\nport 443\r\ncipher AES-256-CBC\r\ncomp-lzo yes\r\nnobind\r\nauth-nocache\r\nscript-security 2\r\npersist-key\r\npersist-tun\r\nauth sha384\r\n\r\n&lt;ca&gt;\r\n$(cat ~\/easy-rsa\/keys\/ca.crt)\r\n&lt;\/ca&gt;\r\n\r\n&lt;cert&gt;\r\n$(cat ~\/easy-rsa\/keys\/client.crt)\r\n&lt;\/cert&gt;\r\n\r\n&lt;key&gt;\r\n$(cat ~\/easy-rsa\/keys\/client.key)\r\n&lt;\/key&gt;\r\n\r\n&lt;tls-auth&gt;\r\n$(cat ~\/easy-rsa\/keys\/ta.key)\r\n&lt;\/tls-auth&gt;\r\n_EOF_\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>So, I decided it was time to prevent some firewalls from blocking my connection to openvpn. Here&#8217;s what I did to share port 443 ( which I already had an apache listening on ) with openvpn ! # Make apache Listen on port 4545 and replace all VirtualHost directives to use that. emerge net-misc\/openvpn app-crypt\/easy-rsa &hellip; <a href=\"https:\/\/serverstuff.info\/wordpress\/2014\/10\/26\/openvpn-setup-with-mysql-auth-and-ssl-port-sharing\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">OpenVPN setup with mysql auth and ssl port sharing<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,6],"tags":[],"class_list":["post-18","post","type-post","status-publish","format-standard","hentry","category-gentoo","category-openvpn"],"_links":{"self":[{"href":"https:\/\/serverstuff.info\/wordpress\/wp-json\/wp\/v2\/posts\/18","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/serverstuff.info\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/serverstuff.info\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/serverstuff.info\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/serverstuff.info\/wordpress\/wp-json\/wp\/v2\/comments?post=18"}],"version-history":[{"count":10,"href":"https:\/\/serverstuff.info\/wordpress\/wp-json\/wp\/v2\/posts\/18\/revisions"}],"predecessor-version":[{"id":26,"href":"https:\/\/serverstuff.info\/wordpress\/wp-json\/wp\/v2\/posts\/18\/revisions\/26"}],"wp:attachment":[{"href":"https:\/\/serverstuff.info\/wordpress\/wp-json\/wp\/v2\/media?parent=18"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/serverstuff.info\/wordpress\/wp-json\/wp\/v2\/categories?post=18"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/serverstuff.info\/wordpress\/wp-json\/wp\/v2\/tags?post=18"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}