-
Notifications
You must be signed in to change notification settings - Fork 0
TP3
Noms des auteurs : Nathan Colson et WILLEMS Julien Date de réalisation : 23/02/2025
- Fait
Commande :
sudo apt update && sudo apt upgrade
Validation :
Le système a été mis à jour sans erreur. Les paquets sont à jour, comme confirmé par la commande apt list --upgradable.
- Fait
Commande :- Modification du fichier de configuration SSH :
sudo nano /etc/ssh/sshd_config
Ajout de la ligne :
Port 444 - Redémarrage du service SSH :
sudo systemctl restart ssh
Validation :
La connexion SSH fonctionne uniquement avec le nouveau port :
ssh -p 444 nathan_nul@adresse_ip
La connexion sur l'ancien port (22) est refusée.
- Modification du fichier de configuration SSH :
- Fait
Commande :- Création de l'utilisateur :
sudo adduser nathan_nul - Ajout de l'utilisateur au groupe
docker:
sudo usermod -aG docker nathan_nul
Validation : - Vérification des groupes de l'utilisateur :
groups nathan_nul
Résultat : nathan_nul : nathan_nul docker - Test des droits restreints :
sudo apt update
Résultat : L'utilisateur ne peut pas exécuter de commandessudosans être ajouté au groupesudo.
- Création de l'utilisateur :
- Fait
Commande :- Modification du fichier de configuration SSH :
sudo nano /etc/ssh/sshd_config
Ajout de la ligne :
PermitRootLogin no - Redémarrage du service SSH :
sudo systemctl restart ssh
Validation :
Tentative de connexion en tant queroot:
ssh -p 444 root@adresse_ip
Résultat : Permission denied (publickey)
- Modification du fichier de configuration SSH :
- Fait
Commande :- Installation d'
ufw:
sudo apt install ufw - Configuration des règles :
sudo ufw allow 444/tcp (Port SSH)
sudo ufw allow 80/tcp (Port HTTP)
sudo ufw allow 53/tcp (Port DNS - TCP)
sudo ufw allow 53/udp (Port DNS - UDP)
sudo ufw enable
Validation : - Vérification des règles :
sudo ufw status
Résultat :Status: active To Action From -- ------ ---- 4952/tcp ALLOW Anywhere 80/tcp ALLOW Anywhere 53/tcp ALLOW Anywhere 53/udp ALLOW Anywhere
- Installation d'
- Fait
Commande :- Installation de Fail2ban :
sudo apt install fail2ban - Configuration de Fail2ban pour SSH :
sudo nano /etc/fail2ban/jail.local
Ajout des lignes :[sshd] enabled = true port = 444 filter = sshd logpath = /var/log/auth.log maxretry = 3 bantime = 600 - Redémarrage de Fail2ban :
sudo systemctl restart fail2ban
Validation : - Vérification du statut de Fail2ban :
sudo fail2ban-client status sshd
Résultat : Fail2ban est actif et surveille le port SSH.
- Installation de Fail2ban :
- Fait
Commande :
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_nathan
Validation :
La clé a été générée et stockée dans ~/.ssh/id_ed25519_nathan.
Commande :
ssh-copy-id -i ~/.ssh/id_ed25519_nathan.pub -p 444 nathan_nul@adresse_ip
Validation :
La connexion SSH fonctionne sans mot de passe :
ssh -i ~/.ssh/id_ed25519_nathan -p 444 nathan_nul@adresse_ip
Commande :
-
Modification du fichier de configuration SSH :
sudo nano /etc/ssh/sshd_config
Ajout des lignes :
PasswordAuthentication no
PermitEmptyPasswords no -
Redémarrage du service SSH :
sudo systemctl restart ssh
Validation :
Tentative de connexion avec un mot de passe :
ssh -p 4952 nathan_nul@adresse_ip
Résultat : Permission denied (publickey)
Commande :
- Création du site web :
mkdir ~/mon-site-web
cd ~/mon-site-web
nano index.html
Contenu deindex.html:
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mon Site Web</title>
</head>
<body>
<h1>Bienvenue sur mon site web !</h1>
<p>Ce site est hébergé dans un conteneur Docker.</p>
</body>
</html>Création du Dockerfile : nano Dockerfile
Contenu du Dockerfile :
FROM nginx:alpine
COPY index.html /usr/share/nginx/html/index.html
EXPOSE 80Construction de l'image Docker : docker build -t mon-site-web .
Lancement du conteneur : docker run -d -p 80:80 --name mon-site-web mon-site-web
Validation : Le site web est accessible à l'adresse : Lien du site (le vps vps-f7e6d9fb.vps.ovh.net)