How to Upload Folder to Google Cloud Vm


To transfer files to Compute Engine VM instances, different options are available depending on your workstation Bone and the target VM instance Bone.

Transfer from To Linux VMs
Linux or macOS
  • Cloud Storage
  • Google Cloud CLI
  • SSH in the browser
  • SCP
Windows
  • Cloud Storage
  • Google Cloud CLI
  • WinSCP

Transfer files through Deject Storage

Deject Storage buckets can exist a user-friendly intermediate transfer betoken between you and your VMs.

This file transfer method works on most all operating systems and VM types as long as your VM has access to your Cloud Storage saucepan through a service account or through your personal user credentials.

Upload your files from your workstation to a Cloud Storage bucket. And so, download those files from the saucepan to your instances.

  1. Create a Cloud Storage bucket or place an existing saucepan that you want to employ to transfer files.
  2. From your workstation, upload files to the bucket.
  3. Connect to your VM using SSH.
  4. On your VM, download files from the bucket.

If y'all need to transfer files in the other direction, opposite the procedure. Upload the files from your VM, and and so download those files to your workstation.

Transfer files using SSH in the browser

If you can found an SSH connection to a VM using the SSH from the Browser window, you can utilize that connection to transfer files to the VM.

  1. In the Cloud Console, go to the VM instances page.

    Go to VM instances

  2. In the list of virtual motorcar instances, click SSH in the row of the case that you want to connect to.

    SSH button next to instance name.

  3. After the connection is established, click the gear icon in the upper right of the SSH from the Browser window and select Upload file. Alternatively, select Download file to download a file from the VM.
    Gear icon menu.
  4. The transfer dialog opens. Specify which file you want to transfer.

If you lot uploaded a file, the file is in your /home/USER directory.

If you downloaded a file, the file is in the default download folder on your local workstation.

Transfer files using the Google Deject CLI

The Google Cloud CLI provides an SCP file transfer utility, creating an SSH key pair for you the first time you connect. Your private key is stored on your local device and its respective public primal is copied to project or VM instance metadata.

To transfer files using SCP, you lot must have a firewall rule on the network that your VM uses that allows SSH connections on port 22. You can verify that this firewall rules exists by looking for a firewall rule that allows tcp:22 connections in the Google Deject Console.

Go to Firewall rules

If yous don't have a firewall rule that allows SSH connections on port 22, create the firewall dominion.

You can install the gcloud CLI and use it to re-create files and directories to your VM using the scp command.

The following instance copies a file from your workstation to the home directory of the VM.

gcloud compute scp          LOCAL_FILE_PATH          VM_NAME:~        

Supercede the following:

  • LOCAL_FILE_PATH : the path to the file on your workstation
  • VM_NAME : the proper name of your VM

You can also copy files and directories from a VM to your local workstation. The following example recursively copies a directory from your VM (the source) to your local workstation (the destination).

gcloud compute scp --recurse          VM_NAME:REMOTE_DIR          LOCAL_DIR        

Replace the following:

  • VM_NAME : the name of the VM
  • REMOTE_DIR : the path to the directory on your VM
  • LOCAL_DIR : the path where you want to put the directory on your workstation

For more information, meet the gcloud compute scp reference documentation.

Transfer files using SCP on Linux and macOS workstations

The scp command-line tool works similarly to the gcloud compute scp command but requires you to manually manage your SSH keys.

To transfer files using SCP, you must have a firewall rule on the network that your VM uses that allows SSH connections on port 22. You lot tin can verify that this firewall rules exists by looking for a firewall dominion that allows tcp:22 connections in the Google Cloud Panel.

Go to Firewall rules

If you lot don't take a firewall rule that allows SSH connections on port 22, create the firewall rule.

The scp tool uses the same central files that yous use to connect to your instances using standard SSH.

  1. If you have not yet applied a public primal to your Google Cloud Console project or VM instance, create an SSH key pair and add the public fundamental to project or instance metadata.

  2. Find the external IP for the VM that y'all desire to send files to. In the Google Cloud Panel, become to the VM instances folio.

    Go to VM instances

  3. Utilize the scp tool to copy a file from your workstation to the home directory of the target VM. For this example, the private key is at ~/.ssh/my-ssh-cardinal.

    scp -i ~/.ssh/my-ssh-key              LOCAL_FILE_PATH              USERNAME@IP_ADDRESS:~            

    Replace the following:

    • LOCAL_FILE_PATH : the name of the local file that you want to upload
    • USERNAME : your username
    • IP-Accost : the external IP address for your VM

You tin can likewise copy files from a VM to your local workstation past reversing the source and destination variables. For this example, re-create a file from your VM to a path on your workstation.

scp -i ~/.ssh/my-ssh-key          USERNAME@IP_ADDRESS:REMOTE_FILE_PATH          LOCAL_FILE_PATH        

Replace the post-obit:

  • USERNAME : your username
  • IP_ADDRESS : the external IP accost for your VM
  • REMOTE_FILE_PATH : the name of the remote file that you desire to download
  • LOCAL_FILE_PATH : the location on your workstation where you want to download the file to

Transfer files using WinSCP on Windows workstations

On Windows workstations, the WinSCP client lets you manage files on your instances through a graphical file browser interface.

WinSCP uses the same key files that you apply to connect to your instances using PuTTY.

  1. Exercise the following if you oasis't configured fundamental-based SSH hallmark for your case:

    1. Create an SSH cardinal pair.

    2. Add your public SSH key to your projection's metadata or to your VM's metadata. For more than information, see Add SSH keys to project metadata or Add SSH keys to case metadata.

  2. Find the external IP for the VM that you want to send files to.

    1. In the Google Deject Console, go to the VM instances page.

      Become to VM instances

    2. In the listing of VMs, detect the external IP address in the External IP column for your VM.
  3. Download and install WinSCP. The default install settings work for about users.

  4. Starting time the WinSCP program. A login window opens where you tin can configure your connexion settings.

  5. In WinSCP, configure your connection settings.

    1. Select SCP every bit the file transfer protocol in the File protocol field.

    2. In the Host Proper name field, specify the external IP accost for the VM that you want to connect to.

    3. In the User name field, specify the Google username that you lot use to access your project. For this case, the user is example-user.

      Setting the file protocol to SCP, the host name to 104.196.31.103, and the user name to example-user.

  6. Click the Avant-garde drop-down list to open the advanced settings, and navigate to SSH > Hallmark.

  7. In the Private key file box, specify the path to your private central file of the SSH key pair that you created for the VM.

    Setting the private key file to my-ssh-key.ppk in the Advanced Site Settings dialog.

  8. Click Ok to save the avant-garde settings.

  9. Click Login to connect to your VM. If the connection is successful, the window opens your local file organization on the left and the VM'south file system on the right. You can navigate to different directories in these file systems and drag files to transfer them to and from your VM.

  10. Yous probable practise non accept permission to manage nearly files outside of your home directory of the VM. Navigate to the habitation directory of the VM:

    /home/USERNAME            
  11. Utilise the WinSCP interface to movement files between your workstation and the VM.

  12. Afterward you copy your files to the VM, connect to your example so that you can execute or motility files with total sudo permissions.

What'south next

  • Connect to your instances to apply the files that you uploaded.

arcewithnswo1966.blogspot.com

Source: https://cloud.google.com/compute/docs/instances/transfer-files

0 Response to "How to Upload Folder to Google Cloud Vm"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel