Correction erreur de code dans le script de connexion ssh

Correction de la condition dans le script de connexion SSH.
La condition avant modification ne permettait pas de connexion
sans la configuration d'une méthode d'authentification, et ne
vérifiait pas la présence du fichier contenant la clé privée
lors de l'utilisation de la méthode key.
This commit is contained in:
Siphonight 2024-12-06 08:49:34 +01:00
parent 83916d00b8
commit f19f8d718a
2 changed files with 3 additions and 3 deletions

View File

@ -4,7 +4,7 @@ FROM alpine:3.20.0 AS monosphere-builder
#Setting default settings, please change them at run #Setting default settings, please change them at run
ARG MONOSPHERE_VERSION="1.0.2 Alpha" ARG MONOSPHERE_VERSION="1.0.3 Alpha"
#Defining build settings #Defining build settings

View File

@ -49,9 +49,9 @@ function main_menu () {
local selected_server local selected_server
selected_server="${server_map[$choice]}" selected_server="${server_map[$choice]}"
echo "Connexion à $( echo "$selected_server" | cut -d " " -f -3)..." echo "Connexion à $( echo "$selected_server" | cut -d " " -f -3)..."
if [ -z "$(echo "$selected_server" | cut -d ' ' -f 4)" ] && [ -f "$AUTHORIZED_SERVERS_PATH"/"$(echo "$selected_server" | cut -d ' ' -f 5)" ]; then if [ -z "$(echo "$selected_server" | cut -d ' ' -f 4)" ]; then
ttyrec -z --"$(echo "$selected_server" | cut -d ' ' -f 1)"-"$(echo "$selected_server" | cut -d ' ' -f 3)"-- -k 300 --warn-before-kill 60 -- ssh -o StrictHostKeyChecking=accept-new -p "$(echo "$selected_server" | cut -d ' ' -f 2)" "$(echo "$selected_server" | cut -d ' ' -f 3)"@"$(echo "$selected_server" | cut -d ' ' -f 1)" ttyrec -z --"$(echo "$selected_server" | cut -d ' ' -f 1)"-"$(echo "$selected_server" | cut -d ' ' -f 3)"-- -k 300 --warn-before-kill 60 -- ssh -o StrictHostKeyChecking=accept-new -p "$(echo "$selected_server" | cut -d ' ' -f 2)" "$(echo "$selected_server" | cut -d ' ' -f 3)"@"$(echo "$selected_server" | cut -d ' ' -f 1)"
elif [ "$(echo "$selected_server" | cut -d ' ' -f 4)" == "key" ]; then elif [ "$(echo "$selected_server" | cut -d ' ' -f 4)" == "key" ] && [ -f "$AUTHORIZED_SERVERS_PATH"/"$(echo "$selected_server" | cut -d ' ' -f 5)" ]; then
eval "$(ssh-agent)" > /dev/null eval "$(ssh-agent)" > /dev/null
trap 'kill $SSH_AGENT_PID' EXIT trap 'kill $SSH_AGENT_PID' EXIT
cat /"$AUTHORIZED_SERVERS_PATH"/"$(echo "$selected_server" | cut -d ' ' -f 5)" | ssh-add - > /dev/null cat /"$AUTHORIZED_SERVERS_PATH"/"$(echo "$selected_server" | cut -d ' ' -f 5)" | ssh-add - > /dev/null