Table des matières

Virtualisation avec virt-manager

Installation d’une VM debian sur un serveur debian

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