Code source wiki de Configuration Linux
Version 21.1 par Guillaume Colson le 16/03/2018 - 15:22
Afficher les derniers auteurs
author | version | line-number | content |
---|---|---|---|
1 | |||
2 | |||
3 | |||
4 | |||
5 | {{confluence_section}} | ||
6 | {{confluence_column width="30%"}} | ||
7 | (% style="text-align: center;" %) | ||
8 | [[image:attach:linux.png||title="linux.png"]] | ||
9 | {{/confluence_column}} | ||
10 | |||
11 | {{confluence_column}} | ||
12 | {{panel}} | ||
13 | |||
14 | |||
15 | {{toc/}} | ||
16 | {{/panel}} | ||
17 | {{/confluence_column}} | ||
18 | {{/confluence_section}} | ||
19 | |||
20 | |||
21 | |||
22 | = Configuration Linux (Ubuntu - Mint) = | ||
23 | |||
24 | 3 solutions : | ||
25 | |||
26 | 1. Via le script d'install Cisco vpn anyconnect | ||
27 | 1. Via le package openconnect (compatible AnyConnect) : Open client for Cisco AnyConnect VPN | ||
28 | 1. Via network-manager + vpnc (compatible Cisco IPSec) | ||
29 | |||
30 | == Configuration VPN Network Manager/vpnc == | ||
31 | |||
32 | === Installation === | ||
33 | |||
34 | Network Manager, le logiciel qui gère les connexions réseaux que l'on trouve sous différentes distributions Linux (ici Ubuntu) sait gérer les connexions [[WiFi>>url:http://wikidocs.univ-lorraine.fr/display/WiFi/Configuration+Network+Manager||shape="rect"]] et VPN UHP. Pour la gestion du VPN, vous devez disposer bien sûr de Network Manager, mais aussi du client vpnc : | ||
35 | |||
36 | ((( | ||
37 | (% class="syntaxhighlighter nogutter java" %) | ||
38 | ((( | ||
39 | |||
40 | |||
41 | |((( | ||
42 | (% class="container" title="Hint: double-click to select code" %) | ||
43 | ((( | ||
44 | (% class="line number1 index0 alt2" %) | ||
45 | ((( | ||
46 | {{code language="none"}} | ||
47 | > apt-get install vpnc | ||
48 | {{/code}} | ||
49 | ))) | ||
50 | ))) | ||
51 | ))) | ||
52 | ))) | ||
53 | ))) | ||
54 | |||
55 | Et enfin, du plugin network-manager-vpnc : | ||
56 | |||
57 | ((( | ||
58 | (% class="syntaxhighlighter nogutter java" %) | ||
59 | ((( | ||
60 | |||
61 | |||
62 | |((( | ||
63 | (% class="container" title="Hint: double-click to select code" %) | ||
64 | ((( | ||
65 | (% class="line number1 index0 alt2" %) | ||
66 | ((( | ||
67 | {{code language="none"}} | ||
68 | > apt-get install network-manager-vpnc | ||
69 | {{/code}} | ||
70 | ))) | ||
71 | ))) | ||
72 | ))) | ||
73 | |||
74 | Pour gnome, il faut également: | ||
75 | |||
76 | {{code language="bash" theme="Confluence"}} | ||
77 | apt install network-manager-vpnc-gnome | ||
78 | {{/code}} | ||
79 | |||
80 | {{error}} | ||
81 | Si vous venez d'installer les paquets précédents (vpnc, network-manager-vpnc, etc ...), alors vous devez redémarrer votre poste de travail ! | ||
82 | {{/error}} | ||
83 | ))) | ||
84 | ))) | ||
85 | |||
86 | === Configuration === | ||
87 | |||
88 | Faites un clique droit sur l’icône de Network Manager dans la zone de notification, puis Modification des connexions ... puis rendez-vous dans l'onglet VPN, si vous avez bien installé le plugin vpnc, alors vous pouvez **//AJOUTER//** un profil. | ||
89 | |||
90 | Cliquez sur CREER, vous obtenez alors : | ||
91 | |||
92 | [[image:attach:Capture_001.png||thumbnail="true" width="300"]] | ||
93 | |||
94 | Saisissez alors les informations de la page suivantes : | ||
95 | |||
96 | * [[doc:xwiki:publique.dn.com.infra.Services numériques.Documentation officielle VPN.WebHome]] | ||
97 | * Domaine : Ne rien y inscrire | ||
98 | * Méthode chiffrement : **//Sécurisé//** | ||
99 | * Traversée du NAT : **//UDP Cisco//** | ||
100 | Dans l'onglet Paramètres IPv4, ne rien changer car l'adresse doit être attribuée automatiquement. | ||
101 | |||
102 | (% class="panelMacro" %) | ||
103 | ((( | ||
104 | |||
105 | ))) | ||
106 | |||
107 | === Connexion === | ||
108 | |||
109 | Faites un clique droit sur l’icône de Network Manager dans la zone de notification, puis Modification des connexions ... puis rendez-vous dans l'onglet VPN, si vous avez bien installé le plugin vpnc, alors vous pouvez **//AJOUTER//** un profil. | ||
110 | |||
111 | Une fois la connexion établie, l’icône de Network Manager indique un cadenas pour vous informer que la connexion a été établie avec succès. | ||
112 | |||
113 | == Via le script d'install Cisco vpn anyconnect == | ||
114 | |||
115 | Sous linux on peux installer le client anyconnect en lancant le script vpnsetup.sh disponible soit : | ||
116 | |||
117 | ici : | ||
118 | |||
119 | * Linux_X86_64 : [[attach:vpnsetup_64b.sh]] ( Version au 13/02/2013) | ||
120 | * Linux_32 : [[attach:vpnsetup_32b.sh]] ( Version au 13/02/2013) | ||
121 | |||
122 | soit | ||
123 | |||
124 | en allant le chercher sur le [[https:~~/~~/vpn.lothaire.net>>url:https://vpn.lothaire.net||shape="rect"]] | ||
125 | |||
126 | |||
127 | |||
128 | [[image:attach:VPN_Linux1.png||width="800" title="VPN_Linux1.png"]] | ||
129 | |||
130 | puis en cliquant sur le lien ( apres 1, à 2 min) : | ||
131 | |||
132 | [[image:attach:VPN_Linux2.png||title="VPN_Linux2.png"]] | ||
133 | |||
134 | |||
135 | |||
136 | Une fois le script récuperé, on install le produit : | ||
137 | |||
138 | |||
139 | |||
140 | {{code language="bash" theme="RDark" title="install_anyconnect"}} | ||
141 | xxxxxx@pcxxxxx ~/Téléchargements $ sudo sh vpnsetup_64b.sh | ||
142 | [sudo] password for xxxxxx: | ||
143 | Installing Cisco AnyConnect Secure Mobility Client... | ||
144 | Removing previous installation... | ||
145 | mv: impossible d'évaluer «/opt/cisco/vpn/*.log»: Aucun fichier ou dossier de ce type | ||
146 | Extracting installation files to /tmp/vpn.zFF5b4/vpninst095927597.tgz... | ||
147 | Unarchiving installation files to /tmp/vpn.zFF5b4... | ||
148 | Starting the VPN agent... | ||
149 | Done! | ||
150 | |||
151 | |||
152 | {{/code}} | ||
153 | |||
154 | |||
155 | |||
156 | on doit rebooter sa machine, pour voir apparaître dans un menu l'application "Cisco Anyconnect Secure Mobility Client" : | ||
157 | |||
158 | [[image:attach:VPN_Linux3.png||title="VPN_Linux3.png"]] | ||
159 | |||
160 | ** | ||
161 | ** | ||
162 | |||
163 | on le lance : | ||
164 | |||
165 | **[[image:attach:VPN_Linux4.png||title="VPN_Linux4.png"]]** | ||
166 | |||
167 | ** | ||
168 | ** | ||
169 | |||
170 | **on accepte le certificat et on peut se connecter :** | ||
171 | |||
172 | ** | ||
173 | ** | ||
174 | |||
175 | **[[image:attach:VPN_Linux5.png||title="VPN_Linux5.png"]]** | ||
176 | |||
177 | **NB : si on a ces erreurs "AnyConnect cannot confirm it is connected to your secure gateway. The local network may not be trustworthy. Please try another network."** | ||
178 | |||
179 | **c'est qu'il manque le certificat TERENA SSL CA** | ||
180 | |||
181 | |||
182 | |||
183 | {{code}} | ||
184 | cd /opt/.cisco/certificates/ca | ||
185 | wget http://www.crium.univ-metz.fr/chaintcs.crt -o chaintcs.pem | ||
186 | {{/code}} | ||
187 | |||
188 | |||
189 | |||
190 | === Fichier XML pour la configuration d'anyconnect === | ||
191 | |||
192 | Dans le cas ou il y a plusieurs concentrateur vpn à gérer. | ||
193 | |||
194 | Fichier à installer dans : | ||
195 | |||
196 | * MacOS X : /opt/cisco/anyconnect/profile | ||
197 | * Windows : (% class="content" %)C:\ProgramData\Cisco\Cisco AnyConnect VPN Client\Profile\ | ||
198 | |||
199 | Mettre un nom suffixé **.xml** | ||
200 | (% class="content" %)\\ | ||
201 | |||
202 | {{code}} | ||
203 | <?xml version="1.0" encoding="UTF-8"?> | ||
204 | |||
205 | <AnyConnectProfile xmlns="http://schemas.xmlsoap.org/encoding/" | ||
206 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
207 | xsi:schemaLocation="http://schemas.xmlsoap.org/encoding/ AnyConnectProfile.xsd"> | ||
208 | <ClientInitialization> | ||
209 | <UseStartBeforeLogon UserControllable="false">false</UseStartBeforeLogon> | ||
210 | <CertEnrollmentPin>pinAllowed</CertEnrollmentPin> | ||
211 | <CertificateMatch> | ||
212 | <KeyUsage> | ||
213 | <MatchKey>Non_Repudiation</MatchKey> | ||
214 | <MatchKey>Digital_Signature</MatchKey> | ||
215 | </KeyUsage> | ||
216 | <ExtendedKeyUsage> | ||
217 | <ExtendedMatchKey>ClientAuth</ExtendedMatchKey> | ||
218 | <ExtendedMatchKey>ServerAuth</ExtendedMatchKey> | ||
219 | <CustomExtendedMatchKey>1.3.6.1.5.5.7.3.11</CustomExtendedMatchKey> | ||
220 | </ExtendedKeyUsage> | ||
221 | <DistinguishedName> | ||
222 | <DistinguishedNameDefinition Operator="Equal" Wildcard="Enabled"> | ||
223 | <Name>CN</Name> | ||
224 | <Pattern>ASASecurity</Pattern> | ||
225 | </DistinguishedNameDefinition> | ||
226 | <DistinguishedNameDefinition Operator="Equal" Wildcard="Disabled"> | ||
227 | <Name>L</Name> | ||
228 | <Pattern>Boulder</Pattern> | ||
229 | </DistinguishedNameDefinition> | ||
230 | </DistinguishedName> | ||
231 | </CertificateMatch> | ||
232 | </ClientInitialization> | ||
233 | <ServerList> | ||
234 | <HostEntry> | ||
235 | <HostName>UL</HostName> | ||
236 | <HostAddress>vpn.lothaire.net</HostAddress> | ||
237 | </HostEntry> | ||
238 | </ServerList> | ||
239 | </AnyConnectProfile> | ||
240 | {{/code}} | ||
241 | |||
242 | |||
243 | |||
244 | == Via le package Openconnect en CLI == | ||
245 | |||
246 | Installation préalable : | ||
247 | |||
248 | {{code}} | ||
249 | sudo apt-get install openconnect | ||
250 | {{/code}} | ||
251 | |||
252 | |||
253 | |||
254 | Commande : | ||
255 | |||
256 | {{code}} | ||
257 | sudo openconnect -u dugravot6@dn-infra --authgroup='Universite-de-Lorraine' --no-cert-check vpn.lothaire.net | ||
258 | {{/code}} | ||
259 | |||
260 | |||
261 | |||
262 | == Via le package Openconnect avec Network-Manager == | ||
263 | |||
264 | On install le package openconnect et les plugin network-manager-openconnect, network-manager-openconnect-gnome | ||
265 | |||
266 | |||
267 | |||
268 | {{code language="bash" theme="RDark" title="Openconnect"}} | ||
269 | sudo apt-get install openconnect network-manager-openconnect network-manager-openconnect-gnome | ||
270 | {{/code}} | ||
271 | |||
272 | |||
273 | |||
274 | rebooter sa machine , on verra maintenant apparaître dans son module de gestion réseau/VPN un nouveau module "VPN Compatible Cisco Anyconnect ( openconnect)" | ||
275 | |||
276 | |||
277 | |||
278 | [[image:attach:VPN_Linux6.png||title="VPN_Linux6.png"]] | ||
279 | |||
280 | |||
281 | |||
282 | [[image:attach:VPN_Linux7.png||title="VPN_Linux7.png"]] | ||
283 | |||
284 | |||
285 | |||
286 | créer , Renseigner uniquement le nomde la connexion et la passerelle | ||
287 | |||
288 | [[image:attach:VPN_Linux8.png||title="VPN_Linux8.png"]] | ||
289 | |||
290 | Pour avoir de bonnes performances il faut activer le Split-Tunnel (seules les connexions nécessaires passent dans le tunnel), | ||
291 | il faut cocher une case dans les paramètres IPV4 > Routes (la traduction française a coupé la phrase) | ||
292 | |||
293 | [[image:attach:openconnect-split-tunnel.jpg||title="openconnect-split-tunnel.jpg"]] | ||
294 | |||
295 | votre nvelle connexion VPN s'affiche maintenant dans votre gestionnaire réseau : | ||
296 | |||
297 | [[image:attach:VPN_Linux9.png||title="VPN_Linux9.png"]] | ||
298 | |||
299 | cocher " Automatically start ....." et cliquer à coté du VPN host pour la connexion : | ||
300 | |||
301 | |||
302 | |||
303 | [[image:attach:VPN_Linux10.png||title="VPN_Linux10.png"]] | ||
304 | |||
305 | valider le certificat : | ||
306 | |||
307 | [[image:attach:VPN_Linux11.png||title="VPN_Linux11.png"]] | ||
308 | |||
309 | |||
310 | |||
311 | puis loguer vous : | ||
312 | |||
313 | |||
314 | |||
315 | [[image:attach:VPN_Linux12.png||title="VPN_Linux12.png"]] | ||
316 | |||
317 | = En cas de problèmes = | ||
318 | |||
319 | == Problème AnyConnect cannot confirm it is connected to your secure gateway == | ||
320 | |||
321 | Lors du démarrage du client Anyconnect, on obtient le message suivant : | ||
322 | |||
323 | [[image:attach:untrust.png||thumbnail="true" width="300"]] | ||
324 | |||
325 | Pour résourde ce problème, procédez comme cela : | ||
326 | |||
327 | 1. ((( | ||
328 | Renommer le dossier ca | ||
329 | |||
330 | {{code}} | ||
331 | cd /opt/.cisco/certificates | ||
332 | mv ca ca.orig | ||
333 | {{/code}} | ||
334 | ))) | ||
335 | 1. ((( | ||
336 | Nouveau dossier | ||
337 | |||
338 | {{code}} | ||
339 | mkdir ca | ||
340 | {{/code}} | ||
341 | ))) | ||
342 | 1. Dans le dossier ca, créez un nouveau certificat, vous pouvez le téléchargez à partir de ce fichier : | ||
343 | [[attach:vpn.pem]] | ||
344 | 1. ((( | ||
345 | Redémarrez le service | ||
346 | |||
347 | {{code}} | ||
348 | /etc/init.d/vpnagentd restart | ||
349 | {{/code}} | ||
350 | ))) | ||
351 | 1. Et le client, le problème ne devrait plus se poser. | ||
352 | |||
353 | == Les accès vers les machines privées ne se font pas depuis l'extérieur == | ||
354 | |||
355 | Il faut modifier la conf du VPN comme ça : | ||
356 | |||
357 | [[image:attach:Capture d'écran de 2015-02-03 12:14:28.png]] |