Jack
Jack

Reputation: 16728

Change gcloud remote user directory

How do I change the home directory to which gcloud copies files. I'm using the following command to copy a file from a local Windows account to Ubuntu which is hosted in a Google Compute Engine instance.

gcloud compute copy-files readme.md compute-engine-instance:readme.md

For some crazy reason the readme file will end up in a remote home directory with the same name as my local user account. I would like to specify which home directory on the compute engine to copy that file to.

Upvotes: 1

Views: 215

Answers (2)

Vilas
Vilas

Reputation: 1455

As you can see in gcloud compute copy-files --help, the command has the following specification:

gcloud compute copy-files [[USER@]INSTANCE:]SRC [[[USER@]INSTANCE:]SRC ...]
    [[USER@]INSTANCE:]DEST [--dry-run] [--plain]
    [--ssh-key-file SSH_KEY_FILE] [--zone ZONE] [GLOBAL-FLAG ...]

You can specify either a user, or a full path to do what you want.

gcloud compute copy-files readme.md user@compute-engine-instance:readme.md

or

gcloud compute copy-files readme.md compute-engine-instance:/home/user/readme.md

The destination can also be a directory. So these would work as well.

gcloud compute copy-files readme.md user@compute-engine-instance:~

or

gcloud compute copy-files readme.md compute-engine-instance:/home/user

Upvotes: 0

Zachary Newman
Zachary Newman

Reputation: 21404

gcloud compute copy-files and other SSH-related commands default to using the name of the local user as the username on the remote host (note that this is very similar to the behavior of plain ssh).

Try gcloud compute copy-files readme.md otheruser@compute-engine-instance: instead.

Upvotes: 1

Related Questions