'gcloud command with timeout option

Is it possible to set max_timeout for gcloud commands. Incase If I want to use gcloud ssh or scp in automation, to login to multiple servers. whole process getting stucked because of some instances getting longer time. Anyway to exit the gcloud command if it reached the max_timeout?



Solution 1:[1]

gcloud has no global and gcloud compute ssh no specific timeout settings.

gcloud compute ssh (and scp) are wrappers around the host's ssh and scp commands.

Configuration options for ssh are summarized in ssh_config man page e.g. -o ConnectTimeout=....

You can set this using gcloud's (!) --ssh-flag flag e.g.

gcloud compute ssh ... --ssh-flag="-o ConnectTimeout=5"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1