# installer un UBUNTU 20.04 LTS 64bits
# installation de Gacamole automatiquement

sudo bash # pour etre Root
wget "http://download.65120.net/guacamole/guac-install.sh" -qO- > inst-guacamole.sh  &&  . inst-guacamole.sh
# login et mot de passe par defaut : guacadmin  guacadmin
http://
apt-get install net-tools

# systemctl enable guacd 
# systemctl start guacd


cat > /etc/netplan/00-installer-config.yaml << FIN_EOF
# This is the network config written by 'subiquity'
network:
  ethernets:
    enp0s3:
      dhcp4: false
      addresses: [192.168.56.200/24]
      gateway4:  192.168.56.1
      nameservers:
              addresses: [8.8.8.8]
  version: 2
FIN_EOF
netplan apply



cat >  /etc/dhcp/dhcpd.conf << FIN_SCRIPT
ddns-update-style none;
ignore client-updates;
subnet 192.168.56.0 netmask 255.255.255.0 {
        option routers 192.168.56.1;
        option subnet-mask 255.255.255.0;
        option domain-name-servers  8.8.8.8;
        range 192.168.56.151 192.168.56.199;
        default-lease-time 21600;
        max-lease-time 43200;

host Kali0 {
  hardware ethernet 08:00:27:00:07:00;
  fixed-address 192.168.56.170;
}	
host Kali1 {
  hardware ethernet 08:00:27:00:07:01;
  fixed-address 192.168.56.171;
}	

host UBUNTU_STAG0 {
  hardware ethernet 08:00:27:00:00:00;
  fixed-address 192.168.56.160;
}
host UBUNTU_STAG1 {
  hardware ethernet 08:00:27:00:00:01;
  fixed-address 192.168.56.161;
}
host UBUNTU_STAG2 {
  hardware ethernet 08:00:27:00:00:02;
  fixed-address 192.168.56.162;
}
host UBUNTU_STAG3 {
  hardware ethernet 08:00:27:00:00:03;
  fixed-address 192.168.56.163;
}
host UBUNTU_STAG4 {
  hardware ethernet 08:00:27:00:00:04;
  fixed-address 192.168.56.164;
}
host UBUNTU_STAG5 {
  hardware ethernet 08:00:27:00:00:05;
  fixed-address 192.168.56.165;
}
host UBUNTU_STAG6 {
  hardware ethernet 08:00:27:00:00:06;
  fixed-address 192.168.56.166;
}
host UBUNTU_STAG7 {
  hardware ethernet 08:00:27:00:00:07;
  fixed-address 192.168.56.167;
}
host UBUNTU_STAG8 {
  hardware ethernet 08:00:27:00:00:08;
  fixed-address 192.168.56.168;
}
host UBUNTU_STAG9 {
  hardware ethernet 08:00:27:00:00:09;
  fixed-address 192.168.56.169;
}

}
FIN_SCRIPT

apt-get install isc-dhcp-server
chmod 777 /var/lib/dhcp/
chmod 777 /var/lib/dhcp/*

# ---------------------------- parametrage Apache2 Reverse proxy vers guacamole

a2enmod  proxy
a2enmod  proxy_http
a2enmod  ssl

cat > /etc/apache2/site-enabled/000-default  << FIN_SCRIPT

<VirtualHost *:443>
 SSLEngine on
 SSLCertificateFile     /WEB/secure.65120.net.crt
 SSLCertificateKeyFile  /WEB/secure.65120.net.key
 ServerName             secure.65120.net
  ProxyPass        "/"  "http://192.168.56.200:8080/guacamole/"
  ProxyPassReverse "/"  "http://192.168.56.200:8080/guacamole/"
  Alias /.well-known/acme-challenge /etc/letsencrypt/challenges/
</VirtualHost>

FIN_SCRIPT

service apache2 restart


