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