28

ファイルを Google Compute Engine にコピーするのに苦労しています。Google Compute Engine で Ubuntu サーバーを使用しています。

私は OS X 端末からこれを行っており、既に使用を許可されていgcloudます。

local:$ gcloud compute copy-files /Users/Bryan/Documents/Websites/gce/index.php example-instance:/var/www/html --zone us-central1-a
Warning: Permanently added '<IP>' (RSA) to the list of known hosts.
scp: /var/www/html/index.php: Permission denied
ERROR: (gcloud.compute.copy-files) [/usr/bin/scp] exited with return code [1].
4

7 に答える 7

18

これが機能しない理由は、ユーザー名が GCE VM インスタンスに対する権限を持っていないため、/var/www/html/.

この質問は Google Compute Engine VM に関するものであるため、VM に として直接 SSH で接続したり、rootファイルを として直接コピーしたりすることはできませんroot。同じ理由で、認証に をgcloud compute copy-files使用しscpています。ssh

可能な解決策:

  1. (コメントでFaizanによっても提案されています)このソリューションには、毎回2つのステップが必要です

    1. gcloud compute copy-filesユーザーが書き込み可能なファイル/ディレクトリを転送するために使用し/tmpます。/home/$USER

    2. gcloud compute sshまたはコンソールのSSHボタンを介して GCE VM にログインし、コピーしsudoて適切な権限を取得します。

      # note: sample command; adjust paths appropriately

      sudo cp -r $HOME/html/* /var/www/html

  2. このソリューションは、いくつかの事前準備作業を伴う 1 つのステップです。

    1. ワンタイム セットアップ: ユーザー名に/var/www/html直接書き込みアクセス権を付与します。これにはいくつかの方法があります。ここに1つのアプローチがあります:

      # make the HTML directory owned by current user, recursively

      sudo chown -R $USER /var/www/html

    2. これで、コピーを 1 ステップで実行できます。

      gcloud compute copy-files /Users/Bryan/Documents/Websites/gce/index.php example-instance:/var/www/html --zone us-central1-a

于 2015-01-11T17:16:26.483 に答える