Cara Akses Google Drive di Linux Server menggunakan rclone

rclone merupakan aplikasi berbasis command line yang berfungsi untuk melakukan sinkronisasi file dan direktori dari/ke berbagai layanan cloud storage atau protokol file server/storage.

Layanan cloud storage yang didukung oleh rclone yaitu Amazon Drive, Amazon S3, Box, Ceph, DigitalOcean Spaces, Dropbox, Google Cloud Storage, Google Drive, Nextcloud, ownCloud, FTP, SFTP, dan masih banyak lagi.

Install rclone

Download dan extract rclone yang sudah berberntuk file binari (sudah di compile).

Download menggunakan curl

curl -O https://downloads.rclone.org/rclone-current-linux-amd64.zip

Extract menggunakan unzip

unzip rclone-current-linux-amd64.zip

Masuk kedalam direktori rclone

cd rclone-*-linux-amd64

Copy file rclone ke direktori /usr/bin/ agar langsung bisa di eksekusi tanpa harus berpindah direktori

sudo cp rclone /usr/bin/

Ubah kepemilikan

sudo chown root:root /usr/bin/rclone

Ubah perizinan

sudo chmod 755 /usr/bin/rclone  

Install manual/(buku panduan) rclone

sudo mkdir -p /usr/local/share/man/man1

Copy file rclone.1 ke direktori /usr/local/share/man/man1

sudo cp rclone.1 /usr/local/share/man/man1/

Update/install mandb

sudo mandb  

Uji hasil install rclone dengan menampilkan nomor versi.

rclone version

Petunjuk pemakaian/manual

man rclone

atau bisa juga membaca dokumentasi resmi di website rclone.

Konfigurasi

Selanjutnya melakukan konfigurasi rclone, menambahkan cloud storage yang ingin dihubungkan ke Linux server.

Jalankan perintah rclone config

rclone config

Jika muncul pertanyaan

2025/07/04 07:33:38 NOTICE: Config file "/home/fariz/.config/rclone/rclone.conf" not found - using defaults
No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n

Jawab n untuk membuat koneksi baru

Jika muncul pertanyaan

Enter name for new remote.
name> drive-saya

Berikan nama koneksinya, contoh: drive-saya

Jika muncul pertanyaan

Option Storage.
Type of storage to configure.
Choose a number from below, or type in your own value.
 1 / 1Fichier
   \ (fichier)
 2 / Akamai NetStorage
   \ (netstorage)
 3 / Alias for an existing remote
   \ (alias)
 4 / Amazon S3 Compliant Storage Providers including AWS, Alibaba, ArvanCloud, Ceph, ChinaMobile, Cloudflare, DigitalOcean, Dreamhost, Exaba, FlashBlade, GCS, HuaweiOBS, IBMCOS, IDrive, IONOS, LyveCloud, Leviia, Liara, Linode, Magalu, Mega, Minio, Netease, Outscale, Petabox, RackCorp, Rclone, Scaleway, SeaweedFS, Selectel, StackPath, Storj, Synology, TencentCOS, Wasabi, Qiniu and others
   \ (s3)
 5 / Backblaze B2
   \ (b2)
 6 / Better checksums for other remotes
   \ (hasher)
 7 / Box
   \ (box)
 8 / Cache a remote
   \ (cache)
 9 / Citrix Sharefile
   \ (sharefile)
10 / Cloudinary
   \ (cloudinary)
11 / Combine several remotes into one
   \ (combine)
12 / Compress a remote
   \ (compress)
13 / DOI datasets
   \ (doi)
14 / Dropbox
   \ (dropbox)
15 / Encrypt/Decrypt a remote
   \ (crypt)
16 / Enterprise File Fabric
   \ (filefabric)
17 / FTP
   \ (ftp)
18 / FileLu Cloud Storage
   \ (filelu)
19 / Files.com
   \ (filescom)
20 / Gofile
   \ (gofile)
21 / Google Cloud Storage (this is not Google Drive)
   \ (google cloud storage)
22 / Google Drive
   \ (drive)
23 / Google Photos
   \ (google photos)
24 / HTTP
   \ (http)
25 / Hadoop distributed file system
   \ (hdfs)
26 / HiDrive
   \ (hidrive)
27 / ImageKit.io
   \ (imagekit)
28 / In memory object storage system.
   \ (memory)
29 / Internet Archive
   \ (internetarchive)
30 / Jottacloud
   \ (jottacloud)
31 / Koofr, Digi Storage and other Koofr-compatible storage providers
   \ (koofr)
32 / Linkbox
   \ (linkbox)
33 / Local Disk
   \ (local)
34 / Mail.ru Cloud
   \ (mailru)
35 / Mega
   \ (mega)
36 / Microsoft Azure Blob Storage
   \ (azureblob)
37 / Microsoft Azure Files
   \ (azurefiles)
38 / Microsoft OneDrive
   \ (onedrive)
39 / OpenDrive
   \ (opendrive)
40 / OpenStack Swift (Rackspace Cloud Files, Blomp Cloud Storage, Memset Memstore, OVH)
   \ (swift)
41 / Oracle Cloud Infrastructure Object Storage
   \ (oracleobjectstorage)
42 / Pcloud
   \ (pcloud)
43 / PikPak
   \ (pikpak)
44 / Pixeldrain Filesystem
   \ (pixeldrain)
45 / Proton Drive
   \ (protondrive)
46 / Put.io
   \ (putio)
47 / QingCloud Object Storage
   \ (qingstor)
48 / Quatrix by Maytech
   \ (quatrix)
49 / SMB / CIFS
   \ (smb)
50 / SSH/SFTP
   \ (sftp)
51 / Sia Decentralized Cloud
   \ (sia)
52 / Storj Decentralized Cloud Storage
   \ (storj)
53 / Sugarsync
   \ (sugarsync)
54 / Transparently chunk/split large files
   \ (chunker)
55 / Uloz.to
   \ (ulozto)
56 / Union merges the contents of several upstream fs
   \ (union)
57 / Uptobox
   \ (uptobox)
58 / WebDAV
   \ (webdav)
59 / Yandex Disk
   \ (yandex)
60 / Zoho
   \ (zoho)
61 / iCloud Drive
   \ (iclouddrive)
62 / premiumize.me
   \ (premiumizeme)
63 / seafile
   \ (seafile)
Storage> 22

Jawab 22 untuk google drive, contoh disini google drive dengan angka 22

Jika muncul pertanyaan

Option client_id.
Google Application Client Id
Setting your own is recommended.
See https://rclone.org/drive/#making-your-own-client-id for how to create your own.
If you leave this blank, it will use an internal key which is low performance.
Enter a value. Press Enter to leave empty.
client_id> 

Tidak perlu di isi, tekan enter

Jika muncul pertanyaan

Option client_secret.
OAuth Client Secret.
Leave blank normally.
Enter a value. Press Enter to leave empty.
client_secret> 

Tidak perlu di isi, tekan enter

Jika muncul pertanyaan

Option scope.
Comma separated list of scopes that rclone should use when requesting access from drive.
Choose a number from below, or type in your own value.
Press Enter to leave empty.
 1 / Full access all files, excluding Application Data Folder.
   \ (drive)
 2 / Read-only access to file metadata and file contents.
   \ (drive.readonly)
   / Access to files created by rclone only.
 3 | These are visible in the drive website.
   | File authorization is revoked when the user deauthorizes the app.
   \ (drive.file)
   / Allows read and write access to the Application Data folder.
 4 | This is not visible in the drive website.
   \ (drive.appfolder)
   / Allows read-only access to file metadata but
 5 | does not allow any access to read or download file content.
   \ (drive.metadata.readonly)
scope> 1

Masukkan angka 1 agar bisa mengakses Google Drive secara penuh (read, write, execute)

Jika muncul pertanyaan

Option service_account_file.
Service Account Credentials JSON file path.
Leave blank normally.
Needed only if you want use SA instead of interactive login.
Leading `~` will be expanded in the file name as will environment variables such as `${RCLONE_CONFIG_DIR}`.
Enter a value. Press Enter to leave empty.
service_account_file> 

Tidak perlu di isi, tekan enter

Jika muncul peertanyaan

Edit advanced config? (y/n)
y) Yes
n) No (default)
y/n> n

Edit advanced config, jawab n

Jika muncul pertanyaan

Use web browser to automatically authenticate rclone with remote?
 * Say Y if the machine running rclone has a web browser you can use
 * Say N if running rclone on a (remote) machine without web browser access
If not sure try Y. If Y failed, try N.

y) Yes (default)
n) No
y/n> n

Jawab n

Lalu akan muncul output berikut

Option config_token.
For this to work, you will need rclone available on a machine that has
a web browser available.
For more help and alternate methods see: https://rclone.org/remote_setup/
Execute the following on the machine with the web browser (same rclone
version recommended):
	rclone authorize "drive" "eyJzY29wZSI6ImRXXXXXXXX"
Then paste the result.
Enter a value.
config_token>

Jika kamu menggunakan windows silakan download rclone untuk windows dan jalankan perintah diatas (yang di highlight) di cmd atau powershell.

Jika kamu menggunakan Linux Desktop silakan download rclone untuk Linux dan jalankan perintah diatas (yang di highlight) di cmd atau powershell.

Ketika perintah diatas dijalankan maka akan muncul jendela browser baru seperti berikut

Izinkan dan lanjutkan

Kembali ke terminal yang menjalankan rclone di windows atau linux desktop

Silakan copy secret dimulai dari setelah remote machine ---> hingga sebelum <--End paste

Pastekan di terminal yang sebelumnya menjlankan rclone di Linux server, seperti berikut

Jika muncul pertanyaan

Configure this as a Shared Drive (Team Drive)?

y) Yes
n) No (default)
y/n> n

Jawab n

JIka muncul overview

Configuration complete.
Options:
- type: drive
- scope: drive
- token: {"access_token":"XXX}
- team_drive: 
Keep this "drive-saya" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y

Jawab y

Jika muncul overview koneksi yang sudah dibuat seperti berikut

Current remotes:

Name                 Type
====                 ====
drive-saya  drive

e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> q

Jawab q untuk keluar dari konfigurasi rclone

Perintah dasar rclone

Selanjutnya mengakses Google Drive melalui rclone dengan menggunakan perintah-perintah yang tersedia.

Menampilkan file

rclone ls drive-saya:

Menampilkan direktori

rclone lsd drive-saya:

Menampilkan file dan direktori

rclone lsf drive-saya:

Membuat direktori

rclone mkdir drive-saya:Nama-direktori

Copy file

rclone copy hello.txt drive-saya:Nama-direktori

Menghapus file, tidak menghapus direktori

rclone delete drive-saya:Nama-direktori

Menghapus direktori yang kosong

rclone rmdir drive-saya:Nama-direktori

Menghapus file dan direktori

rclone purge drive-saya:Nama-direktori

Mount Google Drive di Linux

rclone dapat melakukan mount Google Drive di Linux.

Membuat direktori di home Linux

mkdir ~/google-drive

Jalankan perintah mount dan buat berjalan di latar belakang

rclone mount drive-saya: ~/google-drive &

Maka akan ditampilkan ID proses nya, contoh ID

[1] 2952   

Salin atau simpan kode tersebut. Bilamana kita akan menghentikan/unmount lakukan perintah kill dengan di ikuti nomer ID proses.

Cek isi dari direktori mount ~/google-drive, apakah isinya sama dengan yang ada di Google Drive.

ls -l ~/google-drive

Menghentikan proses rclone mount degan perintah kill ID-proses, contoh ID proses nya adalah 2952

kill 2952

Keterangan artikel

Tested on : Ubuntu 20.04
Sumber & refrensi :
https://musaamin.web.id/cara-akses-google-drive-di-linux-server/