File tree Expand file tree Collapse file tree
modules/black/presidential/Brarner.M.Alete/install Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6161# Try SSH with accept-new for first-time key handshake
6262if ! ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=accept-new -o BatchMode=yes " $REMOTE_USER @$REMOTE_HOST " " echo OK" 2> /dev/null; then
6363 echo " [!] SSH key not accepted. Attempting initial key exchange..."
64+ # Generate keypair if none exists
65+ if [ ! -f ~ /.ssh/id_rsa ] && [ ! -f ~ /.ssh/id_ed25519 ]; then
66+ echo " [*] No SSH key found — generating ed25519 keypair..."
67+ mkdir -p ~ /.ssh && chmod 700 ~ /.ssh
68+ ssh-keygen -t ed25519 -f ~ /.ssh/id_ed25519 -N " " -q
69+ fi
6470 if [ -t 0 ]; then
6571 ssh-copy-id -o ConnectTimeout=10 " $REMOTE_USER @$REMOTE_HOST " 2> /dev/null && \
6672 echo " [*] Key installed successfully" || \
6773 { echo " [!] Key install failed. Try: ssh-copy-id ${REMOTE_USER} @${REMOTE_HOST} " ; exit 1; }
6874 else
69- echo " [!] Cannot SSH (no key, non-interactive). Run: ssh-copy-id ${REMOTE_USER} @${REMOTE_HOST} "
75+ echo " [!] Cannot SSH (non-interactive). Run: ssh-keygen -t ed25519 && ssh-copy-id ${REMOTE_USER} @${REMOTE_HOST} "
7076 exit 1
7177 fi
7278fi
Original file line number Diff line number Diff line change @@ -182,13 +182,19 @@ if [[ "$CONFIRM" =~ ^[Yy]$ ]]; then
182182 elif ! ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=accept-new -o BatchMode=yes " $REMOTE_USER @$REMOTE_HOST " " echo OK" 2> /dev/null; then
183183 # BatchMode fails if no key — try interactive key setup
184184 echo " [!] SSH key not accepted. Attempting initial key exchange..."
185+ # Generate keypair if none exists
186+ if [ ! -f ~ /.ssh/id_rsa ] && [ ! -f ~ /.ssh/id_ed25519 ]; then
187+ echo " [*] No SSH key found — generating ed25519 keypair..."
188+ mkdir -p ~ /.ssh && chmod 700 ~ /.ssh
189+ ssh-keygen -t ed25519 -f ~ /.ssh/id_ed25519 -N " " -q
190+ fi
185191 if [ -t 0 ]; then
186192 ssh-copy-id -o ConnectTimeout=10 " $REMOTE_USER @$REMOTE_HOST " 2> /dev/null && \
187193 echo " [*] Key installed successfully" || \
188194 echo " [!] Key install failed. Try manually: ssh-copy-id ${REMOTE_USER} @${REMOTE_HOST} "
189195 else
190- echo " [!] Cannot SSH to ${REMOTE_HOST} (no key, non-interactive)."
191- echo " Run manually: ssh-copy-id ${REMOTE_USER} @${REMOTE_HOST} "
196+ echo " [!] Cannot SSH to ${REMOTE_HOST} (non-interactive)."
197+ echo " Run: ssh-keygen -t ed25519 && ssh-copy-id ${REMOTE_USER} @${REMOTE_HOST} "
192198 fi
193199 else
194200 # Check existing alias config
You can’t perform that action at this time.
0 commit comments