Улучшение конфигурации SSH: сохранение приватного ключа с точным форматированием и добавлена проверка ключа
Deploy scripts to remote server / Upload and deploy on 192.168.10.14 (push) Failing after 3s
Deploy scripts to remote server / Upload and deploy on 192.168.10.14 (push) Failing after 3s
This commit is contained in:
@@ -199,8 +199,15 @@ jobs:
|
||||
mkdir -p ~/.ssh
|
||||
chmod 700 ~/.ssh
|
||||
|
||||
printf '%s\n' "${DEPLOY_SSH_PRIVATE_KEY}" > ~/.ssh/id_ed25519
|
||||
chmod 600 ~/.ssh/id_ed25519
|
||||
# Save private key preserving exact formatting
|
||||
# Use printf with %b to handle \n sequences, strip trailing whitespace issues
|
||||
echo "${DEPLOY_SSH_PRIVATE_KEY}" | sed 's/\r//' > ~/.ssh/id_deploy
|
||||
# Ensure file ends with a newline (required by OpenSSH)
|
||||
echo "" >> ~/.ssh/id_deploy
|
||||
chmod 600 ~/.ssh/id_deploy
|
||||
|
||||
# Validate key and show fingerprint for debugging
|
||||
echo ">>> Private key type: $(ssh-keygen -l -f ~/.ssh/id_deploy 2>&1 || echo 'INVALID KEY')"
|
||||
|
||||
if [ -n "${DEPLOY_SSH_KNOWN_HOSTS:-}" ]; then
|
||||
printf '%s\n' "${DEPLOY_SSH_KNOWN_HOSTS}" > ~/.ssh/known_hosts
|
||||
@@ -219,7 +226,7 @@ jobs:
|
||||
echo " HostName ${DEPLOY_HOST}"
|
||||
echo " Port ${DEPLOY_PORT}"
|
||||
echo " User ${DEPLOY_USER}"
|
||||
echo " IdentityFile ~/.ssh/id_ed25519"
|
||||
echo " IdentityFile ~/.ssh/id_deploy"
|
||||
echo " UserKnownHostsFile ~/.ssh/known_hosts"
|
||||
echo " StrictHostKeyChecking accept-new"
|
||||
echo " ConnectTimeout 15"
|
||||
|
||||
Reference in New Issue
Block a user