How to auto insert input on gcloud linux command

246 views Asked by At

running this command from my code:

gcloud compute copy-files --zone "$ZONE" "$USER@$SERVER_NAME":"$REMOTE_DIR_LOCATION" "$LOCAL_DIR_LOCATION"

I get this message, for which I want to auto press "enter" 3 times

WARNING: You do not have an SSH key for Google Compute Engine.
WARNING: [/usr/bin/ssh-keygen] will be executed to generate a key.
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):

How do I pass a parameter to gcloud program to notate that I want it to generate the certificates without my manual confirmation.

PS. doing this because my server are dynamically created (so I can't just do it one time for all of them).

PS2 - maybe this is a linux question and not specific to gcloud. I'm open to creative ideas in that direction as well.

1

There are 1 answers

0
Zachary Newman On

Using the --quiet flag with the gcloud compute ssh command will do this for you.

In general, you want the --quiet flag for non-interactive gcloud use.