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