Skip to content

Commit b695859

Browse files
committed
Checks if key transfer failed
1 parent 175cce7 commit b695859

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

sshsetup.sh

100644100755
Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ optionthree () {
233233
menuprompt
234234

235235
else
236-
#Continue with ket creation
236+
#Continue with key creation
237237
proceedprompt
238238
echo
239239
echo "${G}Creating${D} keys ${C}${HOSTVAR}${D} & ${C}${HOSTVAR}.pub${D} at ~/.ssh/. An empty passphrase stores keys in plain text."
@@ -253,14 +253,19 @@ optionthree () {
253253
sleep 0.7
254254
proceedprompt
255255
echo
256-
ssh-copy-id -i "$HOSTVAR".pub -p "$PORTVAR" "$USERVAR"@"$IPVAR"
257-
sleep 0.7
258-
echo "${G}Keys transferred!${D}"
259-
echo
260-
sleep 0.7
261-
echo "${P}Note${D}: Passwordless login via rsa keys won't work until you run option 4 (add ~/.ssh/config entry)."
262-
echo
263-
sleep 0.7
256+
if ssh-copy-id -i "$HOSTVAR".pub -p "$PORTVAR" "$USERVAR"@"$IPVAR"
257+
then
258+
sleep 0.7
259+
echo "${G}Keys transferred!${D}"
260+
echo
261+
sleep 0.7
262+
echo "${P}Note${D}: Passwordless login via rsa keys won't work until you run option 4 (add ~/.ssh/config entry)."
263+
sleep 0.7
264+
else
265+
sleep 0.7
266+
echo "Key transfer ${R}failed!${D} Please check for errors."
267+
echo
268+
fi
264269
menuprompt
265270
fi
266271
fi
@@ -492,13 +497,18 @@ autosetup () {
492497
"fingerprint to your ~/.ssh/known_hosts file. You'll need to provide ssh with ${C}${USERVAR}${D}'s password on ${C}${IPVAR}${D}."
493498
echo
494499
sleep 0.7
495-
ssh-copy-id -i "$HOSTVAR".pub -p "$PORTVAR" "$USERVAR"@"$IPVAR"
496-
sleep 0.7
497-
echo "${G}Keys transferred!${D}"
498-
echo
499-
sleep 0.7
500-
echo "${P}Note${D}: Passwordless login via rsa keys won't work until you run option 4 (add ~/.ssh/config entry)."
501-
sleep 0.7
500+
if ssh-copy-id -i "$HOSTVAR".pub -p "$PORTVAR" "$USERVAR"@"$IPVAR"
501+
then
502+
sleep 0.7
503+
echo "${G}Keys transferred!${D}"
504+
echo
505+
sleep 0.7
506+
echo "${P}Note${D}: Passwordless login via rsa keys won't work until you run option 4 (add ~/.ssh/config entry)."
507+
sleep 0.7
508+
else
509+
sleep 0.7
510+
echo "Key transfer ${R}failed!${D} Please check for errors."
511+
fi
502512
fi
503513
fi
504514
# Config entry
@@ -873,7 +883,7 @@ then
873883

874884
# Present main menu
875885
clear
876-
border "SSH Setup Tool - Linux"
886+
border "SSH Setup Tool - macOS"
877887
echo
878888
echo "${G}1${D} - Install/Update openssh-server (Linux apt-get)"
879889
echo "${G}2${D} - Configure remote host variables"
@@ -1168,4 +1178,4 @@ then
11681178
else
11691179
echo "${C}OSTYPE${D} doesn't return Darwin or Linux. ${R}Exiting${D}..."
11701180
sleep 0.7
1171-
fi
1181+
fi

0 commit comments

Comments
 (0)