Architecture
Sur le Raspberry Pi :
sudo nano /etc/ssh/sshd_config
Ajoute ou modifie ces lignes :
Port 22
PermitRootLogin no
PasswordAuthentication no # Supression de la possibilité de se connecter vbia mot de passe
PubkeyAuthentication yes
AllowTcpForwarding yes # Nécessaire pour le ProxyJump
GatewayPorts no
X11Forwarding no
MaxAuthTries 3
Enfin restart le service ssh pour appliquer la mis a jour de configuration
sudo systemctl restart ssh
Sur chacun des 4 mini PCs, bloquer SSH depuis toute adresse sauf le bastion :
sudo apt update && sudo apt install ufw -y
sudo ufw allow from 192.168.1.26 to any port 22
sudo ufw deny 22
sudo ufw enable
sudo ufw status
Sur chacun des 4 mini PCs :
sudo nano /etc/ssh/sshd_config
Retire l'intégralité du contenu et remplace par :
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
Enfin restart le service ssh pour appliquer la mis a jour de configuration
sudo systemctl restart ssh
Sur ta machine locale:
sudo nano ~/.ssh/config
Met dedans :
# Bastion
Host bastion
HostName ssh.sloudy.xyz
User sanesu # L'utilisateur sur le bastion
IdentityFile ~/.ssh/bastion
ServerAliveInterval 60
# Mini PCs dans le bastion
Host minipc1
HostName 192.168.1.155
User sanesu
ProxyJump bastion
IdentityFile ~/.ssh/bastion
Host 155
HostName 192.168.1.156
User sanesu
ProxyJump bastion
IdentityFile ~/.ssh/bastion
Host 156
HostName 192.168.1.157
User sanesu
ProxyJump bastion
IdentityFile ~/.ssh/bastion
Host 157
HostName 192.168.1.158
User tonuser
ProxyJump bastion
IdentityFile ~/.ssh/bastion
ssh-keygen -t ed25519 -C "m.hepner.ts@gmail.com"
ssh-copy-id -i ~/.ssh/bastion.pub sanesu@192.168.1.26
ssh-copy-id -i ~/.ssh/bastion.pub -o ProxyJump=bastion sanesu@192.168.1.155
ssh-copy-id -i ~/.ssh/bastion.pub -o ProxyJump=bastion sanesu@192.168.1.156
ssh-copy-id -i ~/.ssh/bastion.pub -o ProxyJump=bastion sanesu@192.168.1.157
ssh-copy-id -i ~/.ssh/bastion.pub -o ProxyJump=bastion sanesu@192.168.1.158
ssh bastion
ssh 155
### Ou directement sans config
```bash
ssh -J sanesu@ssh.sloudy.xyz sanesu@192.168.1.155
```
Pour tester que les mini PCs sont bien inaccessibles en direct :
ssh sanesu@192.168.1.155
ssh 155
Le point clé est la règle firewall sur les mini PCs — c'est elle qui garantit qu'aucune connexion SSH n'arrive sans passer par ssh.sloudy.xyz.