Issue Summary
Clients experienced extended deployment times (approx. 30 minutes) when using SFTP to upload theme directories in Atlassian Bitbucket Pipelines. An alternative approach was sought to reduce these times.
Identified Problem
The primary issue was the use of SFTP for deployments, which proved to be slow. A suggestion was made to switch to Rsync, which is faster, but the client faced difficulties with directory errors and SSH configuration.
Proposed Solution
- Switch to Rsync for Faster Deployments: RSYNC, which uses SSH, is significantly quicker than SFTP and can transfer large amounts of data in minutes.
- Correct Rsync Script Configuration:
- Ensure absolute paths are used for both source and destination.
- Use RSYNC flags
-arvz
for better efficiency. - Include the
-e
flag to specify the SSH command. - Example RSYNC command:
bash rsync -arvz -e 'ssh -i ~/.ssh/your-ed25519-key -o IdentitiesOnly=yes' --progress ./source_path $SSHuserName@$SSHHost:/destination_path
- SSH Key Configuration:
- The SSH key (e.g.,
ed25519.pub
) must be added to the SSH authorized keys to avoid password prompts. - Ensure correct permissions for private and public SSH keys (600 for private, 644 for public).
Troubleshooting Common Errors
- Error: “Failed to exec ssh: No such file or directory”
- Solution: Verify the SSH path in the RSYNC command and ensure SSH is correctly installed and accessible.
- Permissions Issue with SSH Key
- Solution: Modify key permissions appropriately. Private key permissions should be set to 600.
- Connection Unexpectedly Closed
- Solution: Check network connectivity and SSH configurations, ensuring the correct keys are in use and properly permissioned.
Successful Deployment Test
- A test deployment using the revised Rsync command was conducted successfully, transferring data quickly without errors.
Final Recommendations
- It is advised to use Rsync with the appropriate flags and SSH configurations for faster, more efficient deployments.
- Regularly check and update SSH key permissions to avoid security issues or connection problems.
Support and Further Assistance
For any additional help or clarification, please reach out to the support team with specific details of the issue.