ajout du sciprt ssh-add-config

This commit is contained in:
2025-03-22 00:17:29 +01:00
parent 8e53c88e95
commit 3b8b279ad4
4 changed files with 43 additions and 0 deletions

View File

@@ -1,3 +1,4 @@
ssh-add-config.sh
trierPhotos.php
castopod_update.sh
check_domain_cert.sh

0
local/bin/castopod_update.sh Normal file → Executable file
View File

42
local/bin/ssh-add-config.sh Executable file
View File

@@ -0,0 +1,42 @@
#!/bin/bash
SSH_CONFIG="$HOME/.ssh/config"
read -p "Nom du Host (alias) : " HOST_NAME
read -p "Adresse du serveur (ex: user@host) : " USER_HOST
read -p "Port SSH (défaut 22) : " PORT
PORT=${PORT:-22}
# Vérifie si le Host existe déjà
if grep -q "Host $HOST_NAME" "$SSH_CONFIG"; then
echo "⚠️ Le Host '$HOST_NAME' existe déjà dans $SSH_CONFIG"
exit 1
fi
# Test de connexion SSH
echo "🔌 Test de connexion SSH vers $USER_HOST sur le port $PORT..."
if ssh -o BatchMode=yes \
-o ConnectTimeout=5 \
-o StrictHostKeyChecking=accept-new \
-p "$PORT" "$USER_HOST" exit 2>/dev/null; then
echo "✅ Connexion réussie"
else
echo "❌ Échec de la connexion SSH. Vérifiez l'adresse ou l'accès."
exit 2
fi
# Ajout dans le fichier ~/.ssh/config
echo "✍️ Ajout de la configuration dans $SSH_CONFIG"
mkdir -p "$HOME/.ssh"
touch "$SSH_CONFIG"
chmod 600 "$SSH_CONFIG"
cat <<EOF >> "$SSH_CONFIG"
Host $HOST_NAME
HostName $(echo "$USER_HOST" | cut -d'@' -f2)
User $(echo "$USER_HOST" | cut -d'@' -f1)
Port $PORT
EOF
echo "✅ Host '$HOST_NAME' ajouté à $SSH_CONFIG"

0
local/bin/update_bullseye2buster.sh Normal file → Executable file
View File