Pipeline Hangs on SSH rm Command
Summary
I have a pretty simple job that always seems to hang on the "rm" commands at the end which clean up temp directories on the target deployment server. If I open an SSH session in a terminal (using the same credentials as the pipeline job) and run these rm commands on the same directories, they execute immediately with no problem. So it seems unlikely that it would have anything to do with the content/size of the directories or the permissions of the user. Eventually (after five minutes or more), the job times out with the message: ssh_exchange_identification: read: Connection timed out
Steps to reproduce
Create a temp directory on the target server. Attempt to remove it using rm.
.gitlab-ci.yml
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- ssh -p22 user_name@target_server.com "mkdir stage_new"
- ssh -p22 user_name@target_server.com "mkdir stage_new/wp-content"
- ssh -p22 user_name@target_server.com "mkdir stage_tmp"
- ssh -p22 user_name@target_server.com "mkdir stage_tmp/wp-content"
- scp -P22 -r $CI_PROJECT_DIR/wp-content/* user_name@target_server.com:stage_new/wp-content
- ssh -p22 user_name@target_server.com "rsync -av htdocs_dir/wp-content stage_tmp"
- ssh -p22 user_name@target_server.com "rsync -av stage_new/wp-content stage_tmp"
- ssh -p22 user_name@target_server.com "rm -rf stage_new/wp-content"
- ssh -p22 user_name@target_server.com "mv htdocs_dir/wp-content/ stage_new/ && mv stage_tmp/wp-content/ htdocs_dir/"
- ssh -p22 user_name@target_server.com "rm -rf stage_tmp"
- ssh -p22 user_name@target_server.com "rm -rf stage_new"
Actual behavior
Job times out after attempting to execute ssh -p22 user_name@target_server.com "rm -rf stage_tmp"
Expected behavior
Directories should be removed and job should be completed.
Relevant logs and/or screenshots
job log
$ ssh -p22 user_name@target_server.com "rm -rf stage_new/wp-content"
ssh_exchange_identification: read: Connection timed out
ERROR: Job failed: exit code 1
Environment description
config.toml contents
Using shared Runners on GitLab.com