wiki:bootstrapwindows

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
wiki:bootstrapwindows [14/05/2024 11:06] – créée vincent.adolphewiki:bootstrapwindows [16/12/2025 17:22] (Version actuelle) vincent.adolphe
Ligne 1: Ligne 1:
 ====== Bootstraper une machine Windows ====== ====== Bootstraper une machine Windows ======
 +===== Version Automatique (script powershell) =====
  
-  * https://doc.cliss21.com/wiki/BootStrapWindows+Dans un powershell admin (clic droit sur le menu démarrer, puis choisir "Terminal (administrateur)" ou "Powershell (admin)" et copier/coller la ligne suivante: 
 +<code bash> 
 +Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://forge.cliss21.org/cliss21/bootstrap/raw/branch/main/windows.ps1')) 
 +</code>
  
 +===== Version manuelle =====
 +
 +==== Accès physique à la machine (écran clavier) ====
 +=== powershell admin  ===
 +  * Ajouter la machine a l'inventaire (récupérer les adresses MAC, attribuer un nom et une IP)
 +  * Nommer la machine
 +  * Créer l'utilisateur "root" si besoin / de même, créer les utilisateurs du poste
 +<code bash>
 +$PASS = 'rootpass'
 +net user root "$PASS" /add
 +net localgroup Administrateurs root /add
 +</code>
 +Sur une installation anglaise, c'est "Administrators"
 +
 +=== powershell admin en tant que root  ===
 +Se connecter avec ce nouveau compte ''root'' (windows initialise des trucs a ce moment là qui simplifie le login ssh sur ce compte par la suite)
 +
 +  * régler les éventuels pb d'antivirus/firewall (certain en s'installant ou se désinstallant modifie le firewall de windows (en pratique laisser l'antivirus fournis avec l'OS et dégager les autres)
 +  * Installer chocolatey (cf https://chocolatey.org/install) cygwin, cyg-get, openssh, ouvrir le firewall et lancer un shell cygwin :<code bash>
 +# install chocolatey
 +Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
 +# install cygwin
 +choco install -y cygwin cyg-get
 +# install ssh, python, rsync in cygwin environment
 +cyg-get.bat openssh python3 rsync
 +# open firewall for SSH and PING
 +netsh advfirewall firewall add rule name="SSH" dir=in action=allow protocol=TCP localport=22
 +netsh advfirewall firewall add rule name="ICMP ping" protocol=icmpv4:8,any dir=in action=allow
 +# Launch a cygwin bash windows
 +C:\tools\cygwin\bin\mintty.exe -
 +</code>
 +
 +=== shell cygwin admin  ===
 +configurer ssh:
 +<code bash>
 +PASS='rootpass'
 +ssh-host-config --yes --name 'sshd' --port 22 --pwd "$PASS"
 +mkpasswd -l > /etc/passwd
 +mkgroup -l > /etc/group
 +cygrunsrv.exe --start sshd
 +</code>
 +
 +==== Accès via SSH ====
 +Un rôle ansible permettant de pousser les clef ssh publique peut être joué a ce moment.
 +
 +  * installer quelques logiciels libres
 +<code bash>
 +choco install -y libreoffice thunderbird firefox vlc
 +</code>
 +  * cacher l'utilisateur "root" au login:<code bash>
 +regtool add '\HKLM\software\microsoft\windows nt\currentversion\winlogon\SpecialAccounts'
 +regtool add '\HKLM\software\microsoft\windows nt\currentversion\winlogon\SpecialAccounts\UserList'
 +regtool -d set '\HKLM\software\microsoft\windows nt\currentversion\winlogon\SpecialAccounts\UserList\root' 0
 +</code>
 +  * vérifier:<code bash>
 +regtool -p list '\HKLM\software\microsoft\windows nt\currentversion\winlogon\SpecialAccounts\UserList'
 +regtool get '\HKLM\software\microsoft\windows nt\currentversion\winlogon\SpecialAccounts\UserList\root'
 +</code>
 +  * Pour créer un profil de mise en veille compatible avec la sauvegarde (pas de mise en veille sur secteur):<code bash>
 +powercfg /duplicatescheme 381b4222-f694-41f0-9685-ff5bb260df2e 381b4222-f694-41f0-9685-ff5bb260df2f
 +# ignorer l'erreur si le profil est deja duplique
 +powercfg /changename 381b4222-f694-41f0-9685-ff5bb260df2f "svg"
 +powercfg /setactive 381b4222-f694-41f0-9685-ff5bb260df2f
 +powercfg /change standby-timeout-ac 0
 +powercfg /change hibernate-timeout-ac 0
 +# desactiver la mise en veille des disques dur:
 +powercfg /SETACVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2f 0012ee47-9041-4b5d-9b77-535fba8b1442 6738e2c4-e8a5-4a42-b16a-e040e769756e 0x0
 +</code>
 +==== Installation TightVNC (Facultatif) ====
 +
 +=== Sur le poste de l'opérateur ===
 +<code bash>
 +VNCPASS="vncpass"
 +apt-get install tigervnc-common
 +PASS=$(echo "$VNCPASS" | vncpasswd -f | hexdump -v -e '/1 "%02x "')
 +echo 'PASS="'$PASS'"'
 +</code>
 +
 +=== Accès via SSH ===
 +
 +<code bash>
 +PASS="hex-pass" # le pass calcule sur la machine de l'operateur
 +choco install -y tightvnc
 +regtool  set '\HKLM\software\tightvnc\server\accepthttpconnections' 0
 +regtool  set '\HKLM\software\tightvnc\server\UseVncAuthentication' 1
 +regtool --binary set '\HKLM\software\tightvnc\server\password' $PASS
 +net stop tvnserver
 +net start tvnserver
 +</code>
 +
 +La GUI de tightvnc s'arrête mais tightvncserver continue a tourner
 +
 +==== Outils divers ====
 +
 +=== paquets chocolatey ===
 +À installer avec un ''%%choco install -y PACKET%%'':
 +  * thunderbird
 +  * firefox
 +  * libreoffice (-> resoud en libreoffice-fresh et dans la langue definie dans les locales)
 +  * chromium (un chrome en moins curieux des donnees personnelles)
 +  * openvpn-community
 +  * 
 +
 +
 +=== Windows10Debloater ===
 +Fonctionne sous windows10 et windows11
 +  * cf https://www.begeek.fr/windows-comment-se-debarrasser-des-bloatwares-en-une-seule-ligne-de-commande-367401
 +  * source: https://github.com/Sycnex/Windows10Debloater
 +  * utilisation <code bash>
 +iwr -useb https://git.io/debloat|iex
 +</code>
 +
 +=== Ajout d'un utilisateur local ===
 +À l'ancienne:
 +
 +<code>
 +net user USERNAME "PASS" /add
 +net localgroup Administrateurs USERNAME /add
 +</code>
 +
 +Version moderne (powershell):
 +<code ps1>
 +$SecurePassword = ConvertTo-SecureString "PASS" -AsPlainText -Force
 +New-LocalUser -Name "USERNAME" -Password $SecurePassword
 +
 +Add-LocalGroupMember -Group "Administrators" -Member "USERNAME"
 +</code>
 +
 +Changer le nom d'affichage:
 +<code ps1>
 +Set-LocalUser -Name "NomCompte" -FullName "Nouveau nom affiché"
 +</code>
 +
 +Renommer un compte (non testé - il y a peut être des effets de bord):
 +<code ps1>
 +Rename-LocalUser -Name "AncienNom" -NewName "NouveauNom"
 +</code>
  • wiki/bootstrapwindows.1715677610.txt.gz
  • Dernière modification : 14/05/2024 11:06
  • de vincent.adolphe