====== Virtualisation avec virt-manager ====== ==== Installation d’une VM debian sur un serveur debian ==== * Création par : [[user>lagrenouille]] * Objet : du tuto qemu-kvm et virt-manager * Niveau requis : {{tag>débutant avisé}} * Commentaires : //Contexte d'utilisation du sujet du tuto. // virtualisation * Débutant, à savoir : [[:doc:systeme:commandes:le_debianiste_qui_papillonne|Utiliser GNU/Linux en ligne de commande, tout commence là !.]] :-) * Suivi : {{tag>à-placer}} * merci à [[user>captnfab]] pour son aide précieuse avec cet article: * [https://debian-facile.org/utilisateurs:captnfab:tutos:libvirt-grenouille] ===== Installation ===== * le client mon ordinateur de bureau * Le Serveur c’est là que l’on installe la VM * Sur le client on installe : apt install virt-manager ssh-askpas * installation en root sur le serveur apt install libvirt qemu-kvm libvirt-daemon-system adduser user libvirt adduser libvirt-qemu mkdir /home/malignum/libvirt-pool chmod 755 /home/malignum/libvirt-pool chown root:libvirt /home/malignum/libvirt chmod 770 /home/malignum/libvirt-pool cd /home/malignum/libvirt-pool qemu-img create -f qcow2 image.qcow2 20G wget https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-10.7.0-amd64-netinst.iso puis $ ls -lha /home/malignum/libvirt-pool/ total 2,6G drwxr-xr-x 2 root libvirt 4,0K janv. 22 16:26 . drwxr-xr-x 17 lagrenouille lagrenouille 4,0K janv. 25 18:25 .. -rw-rw---- 1 libvirt-qemu libvirt-qemu 21G févr. 2 19:47 blz.qcow2 -rw-r--r-- 1 root root 336M déc. 5 13:47 debian-10.7.0-amd64-netinst.iso * installation toujours sur le serveur sudo systemctl status libvirtd.service [sudo] Mot de passe de lagrenouille :  ● libvirtd.service - Virtualization daemon Loaded: loaded (/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2021-01-05 09:22:34 CET; 2 weeks 3 days ago Docs: man:libvirtd(8) https://libvirt.org Main PID: 914 (libvirtd) Tasks: 37 (limit: 32768) Memory: 70.6M CGroup: /system.slice/libvirtd.service ├─ 914 /usr/sbin/libvirtd ├─ 1647 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leas ├─ 1648 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leas ├─ 1773 /usr/bin/qemu-system-x86_64 -name guest=openbsd,debug-threads=on -S -objec └─23246 /usr/bin/qemu-system-x86_64 -name guest=blz-debian10,debug-threads=on -S - janv. 22 22:31:29 lebug dnsmasq-dhcp[1647]: DHCPREQUEST(virbr0) 192.168.122.183 52:54:00:7e:f janv. 22 22:31:29 lebug dnsmasq-dhcp[1647]: DHCPACK(virbr0) 192.168.122.183 52:54:00:7e:fa:0f janv. 22 22:54:54 lebug dnsmasq-dhcp[1647]: DHCPREQUEST(virbr0) 192.168.122.121 52:54:00:5f:9 janv. 22 22:54:54 lebug dnsmasq-dhcp[1647]: DHCPACK(virbr0) 192.168.122.121 52:54:00:5f:95:d0 janv. 22 22:58:32 lebug dnsmasq-dhcp[1647]: DHCPREQUEST(virbr0) 192.168.122.183 52:54:00:7e:f janv. 22 22:58:32 lebug dnsmasq-dhcp[1647]: DHCPACK(virbr0) 192.168.122.183 52:54:00:7e:fa:0f janv. 22 23:17:19 lebug dnsmasq-dhcp[1647]: DHCPREQUEST(virbr0) 192.168.122.121 52:54:00:5f:9 janv. 22 23:17:19 lebug dnsmasq-dhcp[1647]: DHCPACK(virbr0) 192.168.122.121 52:54:00:5f:95:d0 janv. 22 23:25:07 lebug dnsmasq-dhcp[1647]: DHCPREQUEST(virbr0) 192.168.122.183 52:54:00:7e:f janv. 22 23:25:07 lebug dnsmasq-dhcp[1647]: DHCPACK(virbr0) 192.168.122.183 52:54:00:7e:fa:0f lines 1-25/25 (END) * Pour améliorer l’accès à la VM sans taper le password à chaque connexion ssh : * Sur le client donc * installation sur le client ~$ ssh-keygen -f ~/.ssh/labiscouille Generating public/private rsa key pair. Enter passphrase (empty for no passphrase): xxxxxxxxx Enter same passphrase again: xxxxxxxxx Your identification has been saved in /home/momo/.ssh/labiscouille. Your public key has been saved in /home/momo/.ssh/labiscouille.pub. The key fingerprint is: SHA256:4mAyYO89jsCPUFKKOzYtL4Bdili+-/g/GSTDhfg59987OE momo@harthuro The key's randomart image is: +---[RSA 2048]----+ | oo ..oo | | . . .o . | |... . . . | |++. . E| |*.*.o.. S | |*Oo+oo . | |XB.o +. | |=*B.= . | |o+++o= | +----[SHA256]-----+ $ ssh-keygen -f ~/.ssh/labiscouille Generating public/private rsa key pair. Enter passphrase (empty for no passphrase): xxxxxxxxx Enter same passphrase again: xxxxxxxxx Your identification has been saved in /home/momo/.ssh/labiscouille. Your public key has been saved in /home/momo/.ssh/labiscouille.pub. The key fingerprint is: SHA256:4mAyYO89jsCPUFKKOzYtL4Bdili+-/g/GSTDhfg59987OE momo@harthuro The key's randomart image is: +---[RSA 2048]----+ | oo ..oo | | . . .o . | |... . . . | |++. . E| |*.*.o.. S | |*Oo+oo . | |XB.o +. | |=*B.= . | |o+++o= | +----[SHA256]-----+ * copier la clé sur le serveur ssh-copy-id -i ~/.ssh/labiscouille lagrenouille@192.168.1.15 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/momo/.ssh/labiscouille.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys lagrenouille@192.168.1.15's password: * Chaque fois que l’on ouvre une session sur le client, taper : ssh-add /.ssh/labiscouille password * Sur le serveur se connecter en ssh à la debian-VM lagrenouille@lebug:~$ssh root@192.168.122.121 lagrenouille@192.168.122.121's password: Linux blz-debian 4.19.0-13-amd64 #1 SMP Debian 4.19.160-2 (2020-11-28) x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Fri Jan 22 22:24:54 2021 from 192.168.122.1 lagrenouille@blz-debian : $ ls -lha total 24K drwxr-xr-x 2 lagrenouille lagrenouille 4,0K janv. 22 17:32 . drwxr-xr-x 3 root root 4,0K janv. 22 17:28 .. – rw------- 1 lagrenouille lagrenouille 33 janv. 22 22:56 .bash_history – rw-r—r— 1 lagrenouille lagrenouille 220 janv. 22 17:28 .bash_logout – rw-r—r— 1 lagrenouille lagrenouille 3,5K janv. 22 17:28 .bashrc – rw-r—r— 1 lagrenouille lagrenouille 807 janv. 22 17:28 .profile lagrenouille@blz-debian : $ ===== Utilisation Virt-Manager ===== **L’ Installation, la connexion et les informations avec Virt-Manager** {{https://debian-facile.org/images/file-R14cbe39457d20a92a5293cc73a235efd.png}} {{https://debian-facile.org/images/file-R4ec99b2df10557e30a9f9e6fbaf5bcd9.png}} {{https://debian-facile.org/images/file-R4ec99b2df10557e30a9f9e6fbaf5bcd9.png}} {{https://debian-facile.org/images/file-R03f88b70e97a2dcbeb62723b590540f6.png}} {{https://debian-facile.org/images/file-Rb5825479ab48510b2694a8e8d77ab43b.png}} {{https://debian-facile.org/images/file-R5432f8b718d5f440b7053f6576926ccf.png}} {{https://debian-facile.org/images/file-Rf9649d0ff1c35471553f725d86dc9e2f.png}} {{https://debian-facile.org/images/file-Rf175f11e19b41ea4902e9a75187d8969.png}} {{https://debian-facile.org/images/file-R8114e12422cbd4f05366e13577a55f90.png}}