Open kegobass opened 4 years ago
:+1: Running into this issue as well with the same permissive ssh configuration
I also encountered this. It appears to be general flakiness with the Google CloudBuild network. I was able to work around it by adding ssh flags to increase the number of connection attempts. Here are the flags that worked for me:
ConnectionAttempts=20
ConnectTimeout=5
This means that ssh and scp (make sure to use --scp-flag
for scp) will try to connect, wait 5 seconds, and then try again 19 more times. It's possible you may need to adjust these if the network connectivity gets worse but these seem to work consistently for me now.
Example modified commands in run-builder.sh:
$${GCLOUD} compute scp --compress --recurse \
--scp-flag="-o ConnectionAttempts=20" --scp-flag="-o ConnectTimeout=5" \
$(pwd) $${USERNAME}@$${INSTANCE_NAME}:$${REMOTE_WORKSPACE} \
--ssh-key-file=$${KEYNAME}
$${GCLOUD} compute ssh --ssh-key-file=$${KEYNAME} \
--ssh-flag="-o ConnectionAttempts=20" --ssh-flag="-o ConnectTimeout=5" \
$${USERNAME}@$${INSTANCE_NAME} -- $${COMMAND}
ssh: connect to host 35.xxx.xxx.xxx port 22: Connection refused
I added the following to my remote-builder in order to wait and verify the machine is reachable:
CONNECTION_RETRIES=${CONNECTION_RETRIES:-10}
...
retries=0
while ! ${GCLOUD} compute ssh --ssh-key-file=${KEYNAME} \
${USERNAME}@${INSTANCE_NAME} -- exit
do
retries=$((retries+1))
if [[ "$retries" -lt $CONNECTION_RETRIES ]]; then
echo "SSH not ready. Trying again in 5 sec..."
sleep 5
else
echo "ERROR: Couldn't connect to ${INSTANCE_NAME} through SSH"
exit 1
fi
done
I have the same problem to connect to the remote machine. I added the key publishes and tried to connect with
ssh -i id_rsa username@ipexterno
and it is not working.Connection timed out
You can connect only via the Google cloud CLI by clicking ssh connection in instances.
Running into the same issue while trying to run gcloud compute scp....
, any work arounds besides the above ones?
Affected builder image
gcr.io/cloud-builders-community/remote-builder
Expected Behavior
To be able to run through the examples without error
Actual Behavior
Returning error when trying to SSH into instance ssh: connect to host xxxxxxx port 22: Connection timed out
Steps to Reproduce the Problem
Additional Info
Added firewall rule to allow 0.0.0.0/0 ingress for SSH.
Complete error:
--keep-disks
flag is given and specifies them for keeping. Deleting a disk is irreversible and any data on the disk will be lost.Do you want to continue (Y/n)? Deleted [https://www.googleapis.com/compute/v1/projects/dev-monolith-275613/zones/us-central1-f/instances/builder-41e70933-f387-4243-8726-6b4edc3f2d2c]. ERROR ERROR: build step 0 "gcr.io/cloud-solutions-images/remote-builder:v0.3.1" failed: step exited with non-zero status: 1