{"id":1690,"date":"2020-02-17T11:40:38","date_gmt":"2020-02-17T10:40:38","guid":{"rendered":"http:\/\/clark.tipistrani.it\/?p=1690"},"modified":"2020-04-03T09:39:55","modified_gmt":"2020-04-03T07:39:55","slug":"openvpn-su-devuan-linux","status":"publish","type":"post","link":"http:\/\/clark.tipistrani.it\/?p=1690","title":{"rendered":"OpenVPN su Devuan Linux"},"content":{"rendered":"<p>Dopo tanti anni e con il cambiamento a Devuan come Distro di riferimento \u00e8 arrivato il momento di riscrivere due note su OpenVPN.<br \/>\nNon \u00e8 cambiato moltissimo ad onor del vero ma qualcosa si, e quindi come promemoria riscrivo il procedimento.<br \/>\nL&#8217;installazione segue il solito metodo con apt-get install che si tira dietro tutte le dipendenze necessarie.<br \/>\nCreo un symlink a easy-rsa nella directory \/etc\/openvpn con ln -s \/usr\/share\/easy-rsa\/<br \/>\nEntrato in easy-rsa edito il vars e lo modifico in questo modo:<\/p>\n<p>export KEY_COUNTRY=&#8221;IT&#8221;<br \/>\nexport KEY_PROVINCE=&#8221;MI&#8221;<br \/>\nexport KEY_CITY=&#8221;Milano&#8221;<br \/>\nexport KEY_ORG=&#8221;tipistrani&#8221;<br \/>\nexport KEY_EMAIL=&#8221;lamia@email&#8221;<br \/>\nexport KEY_OU=&#8221;System and Networking&#8221;<\/p>\n<p>In questo modo mi evito di scriverli ogni volta che genero un certificato.<br \/>\n. .\/vars<\/p>\n<p>**************************************************************<br \/>\nNo \/etc\/openvpn\/easy-rsa\/openssl.cnf file could be found<br \/>\nFurther invocations will fail<br \/>\n**************************************************************<\/p>\n<p>Primo problema, rapida ricerca in rete e la soluzione \u00e8 pi\u00f9 banale di quanto mi aspettassi, vale a dire un altro symlink <span class=\"crayon-r\">ln<\/span> <span class=\"crayon-o\">&#8211;<\/span><span class=\"crayon-i\">s<\/span> <span class=\"crayon-v\">openssl<\/span><span class=\"crayon-o\">&#8211;<\/span><span class=\"crayon-cn\">1.0.0.cnf<\/span> <span class=\"crayon-v\">openssl<\/span><span class=\"crayon-e\">.cnf<\/p>\n<p>ATTENZIONE NOTA INSERITA DOPO AVERCI PESTATO IL MUSO ED ESSERMI FATTO MOLTO MALE<br \/>\n<\/span><\/p>\n<p>editare il file openssl.cnf e modificare queste due voci<br \/>\ndefault_days = 3650 # how long to certify for<br \/>\ndefault_crl_days= 3650 # how long before next CRL<br \/>\nsoprattutto la seconda che ha valore di default 30 e che se non modificata dopo 30 giorni blocca di fatto la connessione.<\/p>\n<p>&nbsp;<\/p>\n<p>host:\/etc\/openvpn\/easy-rsa# . .\/vars<br \/>\nNOTE: If you run .\/clean-all, I will be doing a rm -rf on \/etc\/openvpn\/easy-rsa\/keys<br \/>\nnoi:\/etc\/openvpn\/easy-rsa# .\/clean-all<br \/>\nnoi:\/etc\/openvpn\/easy-rsa# .\/build-ca<br \/>\nGenerating a RSA private key<br \/>\n.+++++<br \/>\n&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..+++++<br \/>\nwriting new private key to &#8216;ca.key&#8217;<br \/>\n&#8212;&#8211;<br \/>\nYou are about to be asked to enter information that will be incorporated<br \/>\ninto your certificate request.<br \/>\nWhat you are about to enter is what is called a Distinguished Name or a DN.<br \/>\nThere are quite a few fields but you can leave some blank<br \/>\nFor some fields there will be a default value,<br \/>\nIf you enter &#8216;.&#8217;, the field will be left blank.<br \/>\n&#8212;&#8211;<br \/>\nCountry Name (2 letter code) [IT]:<br \/>\nState or Province Name (full name) [MI]:<br \/>\nLocality Name (eg, city) [Milano]:<br \/>\nOrganization Name (eg, company) [tipistrani]:<br \/>\nOrganizational Unit Name (eg, section) [System and Networking]:<br \/>\nCommon Name (eg, your name or your server&#8217;s hostname) [tipistrani CA]:<br \/>\nName [EasyRSA]:<br \/>\nEmail Address [lamia@email]:<br \/>\nSi genera la directory keys come al solito che contiene per ora ca.crt ca.key index.txt serial<br \/>\nDato che l&#8217;esperienza mi ha insegnato che le macchine vanno a $escort e di solito nel momento meno opportuno o che pi\u00f9 banalmente si rifanno con una versione differente di SO e che la memoria umana da per scontate troppe cose ad esempio che in \/etc\/openvpn non ci sono le chiavi e i certificati ma un link a un&#8217;altra directory che le contiene e che quando si rif\u00e0\/recupera una macchina la dir \/etc e&#8217; la prima che si salva io muovo le chiavi in \/etc\/openvpn con un mv keys\/ \/etc\/openvpn\u00a0 e creo all&#8217;interno di \/usr\/share\/easy-rsa\/ un symlink alla directory mossa con ln -s \/etc\/openvpn\/keys e proseguo nella generazione del necessario.<\/p>\n<p>.\/build-key-server server (qui ci metto il nome della macchina che far\u00e0 da server)<br \/>\nGenerating a RSA private key<br \/>\n&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;+++++<br \/>\n&#8230;&#8230;.+++++<br \/>\nwriting new private key to &#8216;server.key&#8217;<br \/>\n&#8212;&#8211;<br \/>\nYou are about to be asked to enter information that will be incorporated<br \/>\ninto your certificate request.<br \/>\nWhat you are about to enter is what is called a Distinguished Name or a DN.<br \/>\nThere are quite a few fields but you can leave some blank<br \/>\nFor some fields there will be a default value,<br \/>\nIf you enter &#8216;.&#8217;, the field will be left blank.<br \/>\n&#8212;&#8211;<br \/>\nCountry Name (2 letter code) [IT]:<br \/>\nState or Province Name (full name) [MI]:<br \/>\nLocality Name (eg, city) [Milano]:<br \/>\nOrganization Name (eg, company) [tipistrani]:<br \/>\nOrganizational Unit Name (eg, section) [System and Networking]:<br \/>\nCommon Name (eg, your name or your server&#8217;s hostname) [noi]:<br \/>\nName [EasyRSA]:<br \/>\nEmail Address [lamia@email]:<\/p>\n<p>Please enter the following &#8216;extra&#8217; attributes<br \/>\nto be sent with your certificate request<br \/>\nA challenge password []:<br \/>\nAn optional company name []:<br \/>\nUsing configuration from \/etc\/openvpn\/easy-rsa\/openssl.cnf<br \/>\nCan&#8217;t open \/etc\/openvpn\/easy-rsa\/keys\/index.txt.attr for reading, No such file or directory<br \/>\n139743276810304:error:02001002:system library:fopen:No such file or directory:..\/crypto\/bio\/bss_file.c:74:fopen(&#8216;\/etc\/openvpn\/easy-rsa\/keys\/index.txt.attr&#8217;,&#8217;r&#8217;)<br \/>\n139743276810304:error:2006D080:BIO routines:BIO_new_file:no such file:..\/crypto\/bio\/bss_file.c:81:<br \/>\nCheck that the request matches the signature<br \/>\nSignature ok<br \/>\nThe Subject&#8217;s Distinguished Name is as follows<br \/>\ncountryName :PRINTABLE:&#8217;IT&#8217;<br \/>\nstateOrProvinceName :PRINTABLE:&#8217;MI&#8217;<br \/>\nlocalityName :PRINTABLE:&#8217;Milano&#8217;<br \/>\norganizationName :PRINTABLE:&#8217;tipistrani&#8217;<br \/>\norganizationalUnitName:PRINTABLE:&#8217;System and Networking&#8217;<br \/>\ncommonName :PRINTABLE:&#8217;server&#8217;<br \/>\nname :PRINTABLE:&#8217;EasyRSA&#8217;<br \/>\nemailAddress :IA5STRING:&#8217;lamia@email&#8217;<br \/>\nCertificate is to be certified until Jan 12 10:25:07 2030 GMT (3650 days)<br \/>\nSign the certificate? [y\/n]:y<\/p>\n<p>1 out of 1 certificate requests certified, commit? [y\/n]y<br \/>\nWrite out database with 1 new entries<br \/>\nData Base Updated<br \/>\nSi pu\u00f2 cominciare a generare i certificati e le chiavi per i client<\/p>\n<p>\/etc\/openvpn\/easy-rsa# .\/build-key pc0<br \/>\nGenerating a RSA private key<br \/>\n&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.+++++<br \/>\n&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;+++++<br \/>\nwriting new private key to &#8216;pc0.key&#8217;<br \/>\n&#8212;&#8211;<br \/>\nYou are about to be asked to enter information that will be incorporated<br \/>\ninto your certificate request.<br \/>\nWhat you are about to enter is what is called a Distinguished Name or a DN.<br \/>\nThere are quite a few fields but you can leave some blank<br \/>\nFor some fields there will be a default value,<br \/>\nIf you enter &#8216;.&#8217;, the field will be left blank.<br \/>\n&#8212;&#8211;<br \/>\nCountry Name (2 letter code) [IT]:<br \/>\nState or Province Name (full name) [MI]:<br \/>\nLocality Name (eg, city) [Milano]:<br \/>\nOrganization Name (eg, company) [tipistrani]:<br \/>\nOrganizational Unit Name (eg, section) [System and Networking]:<br \/>\nCommon Name (eg, your name or your server&#8217;s hostname) [pc0]:<br \/>\nName [EasyRSA]:<br \/>\nEmail Address [lamia@email]:<\/p>\n<p>Please enter the following &#8216;extra&#8217; attributes<br \/>\nto be sent with your certificate request<br \/>\nA challenge password []:<br \/>\nAn optional company name []:<br \/>\nUsing configuration from \/etc\/openvpn\/easy-rsa\/openssl.cnf<br \/>\nCheck that the request matches the signature<br \/>\nSignature ok<br \/>\nThe Subject&#8217;s Distinguished Name is as follows<br \/>\ncountryName :PRINTABLE:&#8217;IT&#8217;<br \/>\nstateOrProvinceName :PRINTABLE:&#8217;MI&#8217;<br \/>\nlocalityName :PRINTABLE:&#8217;Milano&#8217;<br \/>\norganizationName :PRINTABLE:&#8217;tipistrani&#8217;<br \/>\norganizationalUnitName:PRINTABLE:&#8217;System and Networking&#8217;<br \/>\ncommonName :PRINTABLE:&#8217;pc0&#8242;<br \/>\nname :PRINTABLE:&#8217;EasyRSA&#8217;<br \/>\nemailAddress :IA5STRING:&#8217;lamia@email&#8217;<br \/>\nCertificate is to be certified until Jan 12 10:49:08 2030 GMT (3650 days)<br \/>\nSign the certificate? [y\/n]:y<\/p>\n<p>1 out of 1 certificate requests certified, commit? [y\/n]y<br \/>\nWrite out database with 1 new entries<br \/>\nData Base Updated<br \/>\nE a seguire per tutti i client necessari.<br \/>\nGenero i parametri Diffie Hellman<br \/>\n.\/build-dh<\/p>\n<p>Da ultimo genero la chiave per l&#8217;auth tls con<\/p>\n<p>:\/etc\/openvpn\/keys\/ openvpn &#8211;genkey &#8211;secret ta.key<\/p>\n<table>\n<tbody>\n<tr>\n<td>Nome file<\/td>\n<td>Serve su<\/td>\n<td>Scopo<\/td>\n<td>Segreto<\/td>\n<\/tr>\n<tr>\n<td>ca.crt<\/td>\n<td>Server e tutti i client<\/td>\n<td>Certificato principale CA certifica tutti i seguenti<\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td>ca.key<\/td>\n<td>Solo la macchina che firma i certificati<\/td>\n<td>Chiave principale CA cripta tutit i seguenti<\/td>\n<td>S\u00ec<\/td>\n<\/tr>\n<tr>\n<td>dh2048.pem<\/td>\n<td>Solo sul server<\/td>\n<td>Parametro Diffie Hellman aumenta la crittografia<\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td>{n}.pem<\/td>\n<td>Solo sul server<\/td>\n<td>Parametro Diffie Hellman univoco del client aumenta la crittografia<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>server.crt<\/td>\n<td>Solo sul server<\/td>\n<td>Certificato del server<\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td>server.key<\/td>\n<td>Solo sul server<\/td>\n<td>Chiave del server<\/td>\n<td>S\u00ec<\/td>\n<\/tr>\n<tr>\n<td>pc0.crt<\/td>\n<td>Solo PC0<\/td>\n<td>Certificato del client<\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td>pc0.key<\/td>\n<td>Solo PC0<\/td>\n<td>Chiave del client<\/td>\n<td>S\u00ec<\/td>\n<\/tr>\n<tr>\n<td>client{n}.crt<\/td>\n<td>Solo client{n}<\/td>\n<td>Certificato univoco del client<\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td>client{n}.key<\/td>\n<td>Solo client{n}<\/td>\n<td>Chiave univoca del client<\/td>\n<td>S\u00ec<\/td>\n<\/tr>\n<tr>\n<td>ta.key<\/td>\n<td>Server e tutti client<\/td>\n<td>auth-tls<\/td>\n<td>S\u00ec<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>La tabella sopra riportata \u00e8 copiata pari pari dal sito di openvpn e spiega benissimo a cosa servono e dove vanno i files che sono stati generati.<br \/>\nI server come in precedenza devono essere due, uno per i client linux\/android\/apple e uno per i client windows, a questo proposito ci siamo accorti col tempo che i client windows quando erano in giro per il mondo usando le wifi che potevano collegandosi\u00a0 con il protocollo UDP avevano un bel po di problemini e abbiamo deciso di provare a passare a TCP anche con loro, infatti se i client linux possono usare senza problemi sia tcp che udp e i device tun o tap indifferentemente, i device android e apple usano solo tcp e il device tun.<\/p>\n<p>Di seguito le configurazioni per i vari casi sia server che client, aggiungo che abbiamo inserito il Diffie Hellman anche in azienda cosa che prima non usavamo.<\/p>\n<p><a href=\"http:\/\/clark.tipistrani.it\/?p=1697\">Server linux per client linux\/android\/apple<\/a><\/p>\n<p><a href=\"http:\/\/clark.tipistrani.it\/?p=1727\">Server linux per client Windows<\/a><\/p>\n<p><a href=\"http:\/\/clark.tipistrani.it\/?p=1707\">Client per linux<\/a><\/p>\n<p><a href=\"http:\/\/clark.tipistrani.it\/?p=1730\">Client per windows<\/a><\/p>\n<p><a href=\"http:\/\/clark.tipistrani.it\/?p=1703\">Client per android<\/a><\/p>\n<p><a href=\"http:\/\/clark.tipistrani.it\/?p=1711\">Client per apple<\/a><\/p>\n<p><a href=\"http:\/\/clark.tipistrani.it\/?p=1734\">ccd per linux<\/a><br \/>\n<a href=\"http:\/\/clark.tipistrani.it\/?p=1737\">ccd per windows<\/a><\/p>\n<p>Reference: <a href=\"https:\/\/openvpn.net\/community-resources\/how-to\/\">https:\/\/openvpn.net\/community-resources\/how-to\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Dopo tanti anni e con il cambiamento a Devuan come Distro di riferimento \u00e8 arrivato il momento di riscrivere due note su OpenVPN. Non \u00e8 cambiato moltissimo ad onor del vero ma qualcosa si, e quindi come promemoria riscrivo il procedimento. L&#8217;installazione segue il solito metodo con apt-get install che si tira dietro tutte le [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,14,6],"tags":[136,78],"class_list":["post-1690","post","type-post","status-publish","format-standard","hentry","category-linux","category-networking","category-work","tag-devuan","tag-openvpn"],"_links":{"self":[{"href":"http:\/\/clark.tipistrani.it\/index.php?rest_route=\/wp\/v2\/posts\/1690","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/clark.tipistrani.it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/clark.tipistrani.it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/clark.tipistrani.it\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/clark.tipistrani.it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1690"}],"version-history":[{"count":16,"href":"http:\/\/clark.tipistrani.it\/index.php?rest_route=\/wp\/v2\/posts\/1690\/revisions"}],"predecessor-version":[{"id":1740,"href":"http:\/\/clark.tipistrani.it\/index.php?rest_route=\/wp\/v2\/posts\/1690\/revisions\/1740"}],"wp:attachment":[{"href":"http:\/\/clark.tipistrani.it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1690"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/clark.tipistrani.it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1690"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/clark.tipistrani.it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1690"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}