====== Bootstraper une machine Windows ======
===== Version Automatique (script powershell) =====
Dans un powershell admin (clic droit sur le menu démarrer, puis choisir "Terminal (administrateur)" ou "Powershell (admin)" et copier/coller la ligne suivante:
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://forge.cliss21.org/cliss21/bootstrap/raw/branch/main/windows.ps1'))
===== 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
$PASS = 'rootpass'
net user root "$PASS" /add
net localgroup Administrateurs root /add
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 :
# 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 -
=== shell cygwin admin ===
configurer ssh:
PASS='rootpass'
ssh-host-config --yes --name 'sshd' --port 22 --pwd "$PASS"
mkpasswd -l > /etc/passwd
mkgroup -l > /etc/group
cygrunsrv.exe --start sshd
==== 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
choco install -y libreoffice thunderbird firefox vlc
* cacher l'utilisateur "root" au login:
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
* vérifier:
regtool -p list '\HKLM\software\microsoft\windows nt\currentversion\winlogon\SpecialAccounts\UserList'
regtool get '\HKLM\software\microsoft\windows nt\currentversion\winlogon\SpecialAccounts\UserList\root'
* Pour créer un profil de mise en veille compatible avec la sauvegarde (pas de mise en veille sur secteur):
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
==== Installation TightVNC (Facultatif) ====
=== Sur le poste de l'opérateur ===
VNCPASS="vncpass"
apt-get install tigervnc-common
PASS=$(echo "$VNCPASS" | vncpasswd -f | hexdump -v -e '/1 "%02x "')
echo 'PASS="'$PASS'"'
=== Accès via SSH ===
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
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 en PowerShell admin
iwr -useb https://git.io/debloat|iex
=== Ajout d'un utilisateur local ===
À l'ancienne:
net user USERNAME "PASS" /add
net localgroup Administrateurs USERNAME /add
Version moderne (powershell):
$SecurePassword = ConvertTo-SecureString "PASS" -AsPlainText -Force
New-LocalUser -Name "USERNAME" -Password $SecurePassword
Add-LocalGroupMember -Group "Administrators" -Member "USERNAME"
Changer le nom d'affichage:
Set-LocalUser -Name "NomCompte" -FullName "Nouveau nom affiché"
Renommer un compte (non testé - il y a peut être des effets de bord):
Rename-LocalUser -Name "AncienNom" -NewName "NouveauNom"