gsutil is a Python application that lets you access Google Cloud Storage from the command line. You can use gsutil to do a wide range of bucket and object management tasks, including:
[root@aodbatmp]# wget https://storage.googleapis.com/pub/gsutil.tar.gz
--2016-02-01 10:55:19-- https://storage.googleapis.com/pub/gsutil.tar.gz
Resolving storage.googleapis.com... 216.58.220.144, 2404:6800:4006:800::2010
Connecting to storage.googleapis.com|216.58.220.144|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2676340 (2.6M) [application/x-tar]
Saving to: “gsutil.tar.gz”
100%[============================] 2,676,340 2.64M/s in 1.0s
2016-02-01 10:55:21 (2.64 MB/s) - “gsutil.tar.gz” saved [2676340/2676340]
[root@aodbatmp]# tar xfz gsutil.tar.gz -C $HOME
echo 'export PATH=${PATH}:$HOME/gsutil' /root/.bashrc
source /root/.bashrc
[root@aodba]# gsutil --version
gsutil version: 4.16
Set Up Credentials to Access Protected Data
Installing gsutil allows you to download and access publicly-accessible objects, but in order to access protected data or write to a protected bucket, you need to set up credentials to access the Google Cloud Storage service. The first time you run this command, gsutil prints a URL to the authorization page where you can authorize gsutil to access Google Cloud Storage. See steps to follow:[root@aodba/]# gsutil config
This command will create a boto config file at /root/.boto containing
your credentials, based on your responses to the following questions.
Please navigate your browser to the following URL:
https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fd
evstorage.full_control&redirect_uri=urn%etf%3Awg%h%3A2.0%3Aoob&response_type=code&client_id=9924072.apps.googleusercontent.com&access_type=offline
In your browser you should see a page that requests you to authorize access to Google Cloud
Platform APIs and Services on your behalf. After you approve, an authorization code will be displayed.
Enter the authorization code: sdfstersdgdtsdgf/sadeGZTaVuUXzWV8
Please navigate your browser to https://cloud.google.com/console#/project,
then find the project you will use, and copy the Project ID string from the
second column. Older projects do not have Project ID strings. For such projects,
click the project and then copy the Project Number listed under that project.
What is your project-id? myproject-id
Boto config file "/root/.boto" created. If you need to use a proxy to
access the Internet please see the instructions in that file.
[root@aodba/]# gsutil test -u
Running 194 tests sequentially.
194/194 finished - E[0] F[0] s[15] - FileIteratorTests.testRecursiveDire - .
----------------------------------------------------------------------
Ran 194 tests in 13.894s
OK (skipped=15)
Running 80 tests in parallel mode (5 processes).
9/80 finished - 0 failures
17/80 finished - 0 failures
38/80 finished - 0 failures
47/80 finished - 0 failures
55/80 finished - 0 failures
66/80 finished - 0 failures
Test process creation finished (80/80 created)
78/80 finished - 0 failures
78/80 finished - 0 failures
78/80 finished - 0 failures
Parallel tests complete. Success: 80 Fail: 0
Ran 274 tests in 60.598s (194 sequential in 13.906s, 80 parallel in 46.692s)
OK