binbeobo / google-cloud-sdk

Automatically exported from code.google.com/p/google-cloud-sdk
0 stars 1 forks source link

compute copy-files make unnecessary(?) separate connections #376

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Consider these scenarios.

$ gcloud compute copy-files instance:/dir/* dir
$ gcloud compute copy-files instance:/dir/1 instance:/dir/2 dir
$ gcloud compute copy-files instance:/dir/{1,2} dir

In the first case, copy-files only makes one connection, indicated I think by 
only displaying this message once.

Warning: Permanently added '1.2.3.4' (ECDSA) to the list of known hosts.

In both the second and third case it display the message for each file it 
transfers, indicating I think that it makes a separate connection for each.

I don't know if this is a limitation of scp or otherwise.

Original issue reported on code.google.com by pdknsk on 7 Nov 2015 at 12:20

GoogleCodeExporter commented 8 years ago
In this case, the Cloud SDK works exactly as ssh does (edited for 
whitespace/personal information):

    $ gcloud compute copy-files --zone asia-east1-c <hostname>:{1,2,3} /tmp --dry-run
    /usr/local/bin/scp -i /Users/<user>/.ssh/google_compute_engine
        -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o CheckHostIP=no \
        -o StrictHostKeyChecking=no -r \
        <user>@<ip>:1 <user>@<ip>:2 <user>@<ip>:3 /tmp
    $ gcloud compute copy-files --zone asia-east1-c '<hostname>:*' /tmp --dry-run
     /usr/local/bin/scp -i /Users/<user>/.ssh/google_compute_engine \
        -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o CheckHostIP=no \
        -o StrictHostKeyChecking=no -r \
        <user>@<ip>:* /tmp

What you're looking for is '<hostname>:{1,2,3}', so that your shell doesn't 
expand the `{1,2,3}`:

   $ gcloud compute copy-files --zone asia-east1-c '<hostname>:{1,2,3}' /tmp --dry-run
    /usr/local/bin/scp -i /Users/<user>/.ssh/google_compute_engine \
        -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o CheckHostIP=no \
        -o StrictHostKeyChecking=no -r \
        <user>@<ip>:{1,2,3} /tmp

This works exactly as you would like.

Original comment by z...@google.com on 19 Nov 2015 at 3:18

GoogleCodeExporter commented 8 years ago
Thanks!

Original comment by pdknsk on 19 Nov 2015 at 11:09