Adding Files to Instance Disks using SSH

  • date 9th April, 2021 |
  • by Prwatech |
  • 0 Comments

Adding Files to Instance Disks using SSH

 

Prerequisites

Hardware  :  GCP

Google account

We might need some files in the Boot disk rather than bucket. To add the files into boot disk, we have to give the access permissions for the user

Open Cloud Console.

Menu > Compute Engine > VM Instances.

Click SSH of the instance which you want to add the files.

Type     

$             pwd                                                    #show the path of file.

  ls                                                         #list the directory

$             mkdir <directory-name> #It will create a directory

gsutil cp gs://<bucket-name>/<file-name-with-extension> /home/<account-name>/<directory- name>/

If the account have the Storage Object Admin permission, then the above command can be copied. If not, AccessDeniedException will be raised.

To give Storage Object Admin Access Open Menu > IAM.

Click the pencil icon to the respective member which you want to give the permission.

Add role as Storage Object Admin. Then click Save.

Now open the SSH of the instance. Type

$             gcloud init

Select the account by typing corresponding number. If not listed, type 2 to add another account. Then type Y

Click on the link.

Choose the account which we gave the permission.

Click Allow.

Copy the code which is shown.

Paste the code into SSH and press enter.

Choose the project by typing the corresponding number. Type n

Type the below code.

$             gsutil cp gs://<bucket-name>/<file-name-with-extension> /home/<account-name>/<directory- name>/

The file copied into disk.

0
0

Quick Support

image image