Deux facteurs cumulés causaient exit status 255 lors du rebond SSH:
Permissions insuffisantes sur la clé privée (critique)
/etc/sshproxy/gateway_rsa en 600 (root:root)testuser (via ForceCommand sshd)Absence de contrôle PTY explicite (secondaire)
-T ou -tt dans sshproxy.yaml# Avant
RUN mkdir -p /etc/sshproxy
COPY keys/gateway_rsa /etc/sshproxy/gateway_rsa
RUN chmod 600 /etc/sshproxy/gateway_rsa
# Après
RUN mkdir -p /etc/sshproxy && chmod 755 /etc/sshproxy
COPY keys/gateway_rsa /etc/sshproxy/gateway_rsa
RUN chmod 600 /etc/sshproxy/gateway_rsa && chown testuser:testuser /etc/sshproxy/gateway_rsa
ssh:
exe: "/usr/bin/ssh"
args:
- "-v" # Verbose logs
- "-tt" # Force PTY allocation pour shell interactif
- "-i"
- "/etc/sshproxy/gateway_rsa"
- "-o"
- "StrictHostKeyChecking=no"
- "-o"
- "UserKnownHostsFile=/dev/null"
Résultat: ✅ Exit status 0 — rebond SSH fonctionne
sshproxy est conçu comme proxy de commandes, pas multiplexeur de shell.
Quand aucune commande n'est passée:
Créé gateway/sshproxy-wrapper.sh qui détecte:
SSH_ORIGINAL_COMMAND non vide) → proxifier via sshproxy ✓Shell interactif (SSH_ORIGINAL_COMMAND vide) → rejet sécurisé avec message clair
#!/bin/bash
if [ -z "$SSH_ORIGINAL_COMMAND" ]; then
echo "Interactive shells not permitted through sshproxy gateway." >&2
echo "Usage: ssh user@gateway 'command'" >&2
exit 1
else
exec /usr/sbin/sshproxy
fi
Updated gateway/sshd_config:
ForceCommand /usr/sbin/sshproxy-wrapper
# ✓ Commandes exécutées correctement
ssh -p 2222 testuser@gateway 'whoami; hostname; id'
# testuser
# dest2
# uid=1000(testuser) gid=1000(testuser) groups=1000(testuser)
# ✓ Shells interactifs rejetés proprement
ssh -p 2222 testuser@gateway
# Interactive shells not permitted through sshproxy gateway.
# Usage: ssh user@gateway 'command'
Windows SSH Client
↓ (ssh -p 2222 testuser@gateway 'commande')
↓ auth: lab_rsa
Gateway sshproxy (172.30.0.10:22)
├─→ Wrapper détecte commande
└─→ sshproxy proxifie vers:
├─ dest1 (172.30.0.11) — random selection
└─ dest2 (172.30.0.12) — 50% de chance chacun
Métrique: 5 connexions de test → distribution (dest2, dest2, dest2, dest1, dest1) ✓
ed25519 (lab_rsa) + authentification par cléAllowTcpForwarding no)dest1:22, dest2:22gateway/
├── Dockerfile (Fix: permissions testuser + wrapper)
├── sshd_config (Fix: ForceCommand → sshproxy-wrapper)
├── sshproxy.yaml (Fix: ajout -tt pour PTY allocation)
└── sshproxy-wrapper.sh (NEW: détection commande vs shell)
keys/
├── lab_rsa
├── lab_rsa.pub
├── gateway_rsa
└── gateway_rsa.pub
Status: ✅ Lab fonctionnel — prêt pour intégration etcd et DNS Docker