1. Windows下载rclone

下载链接

1.2 获取access_token并保存

.\rclone.exe authorize drive

image

2. vps安装rclone

Ubuntu:
AMD64

wget https://downloads.rclone.org/v1.60.1/rclone-v1.60.1-linux-amd64.deb && dpkg -i rclone-v1.60.1-linux-amd64.deb

ARM64

wget https://downloads.rclone.org/v1.60.1/rclone-v1.60.1-linux-arm64.deb && dpkg -i rclone-v1.60.1-linux-arm64.deb

3. 配置rclone

rclone config
No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n          ##←←←←←输入n
Enter name for new remote.
name> gd     #←←←←名称随便写
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
 1 / A stackable unification remote, which can appear to merge the contents of several remotes
   \ "union"
 2 / Alias for a existing remote
   \ "alias"
 3 / Amazon Drive
   \ "amazon cloud drive"
 4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, etc)
   \ "s3"
 5 / Backblaze B2
   \ "b2"
 6 / Box
   \ "box"
 7 / Cache a remote
   \ "cache"
 8 / Dropbox
   \ "dropbox"
 9 / Encrypt/Decrypt a remote
   \ "crypt"
10 / FTP Connection
   \ "ftp"
11 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
12 / Google Drive
   \ "drive"
13 / Hubic
   \ "hubic"
14 / JottaCloud
   \ "jottacloud"
15 / Local Disk
   \ "local"
16 / Mega
   \ "mega"
17 / Microsoft Azure Blob Storage
   \ "azureblob"
18 / Microsoft OneDrive
   \ "onedrive"
19 / OpenDrive
   \ "opendrive"
20 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
21 / Pcloud
   \ "pcloud"
22 / QingCloud Object Storage
   \ "qingstor"
23 / SSH/SFTP Connection
   \ "sftp"
24 / Webdav
   \ "webdav"
25 / Yandex Disk
   \ "yandex"
26 / http Connection
   \ "http"
Storage>12     ##←←←←←输入32以自己显示的为准
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> ##←←←←←直接回车
Option client_secret.
OAuth Client Secret.
Leave blank normally.
Enter a value. Press Enter to leave empty.
client_secret>   ##←←←←←直接回车
Option scope.
Scope 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 ##←←←←←选第一个1
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>  ##←←←←←直接回车
Edit advanced config?
y) Yes
n) No (default)
y/n> n  ##←←←←←选n
Use auto config?
 * Say Y if not sure
 * Say N if you are working on a remote or headless machine

y) Yes (default)
n) No
y/n>n ##←←←←←选n
Remote config
Use auto config?
 * Say Y if not sure
 * Say N if you are working on a remote or headless machine
y) Yes
n) No
y/n> n   ##←←←←←选n

粘贴一开始获取的access_token
image-1669292461195

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" "eyJzY29wZSI6ImRyaXZlIn0"
Then paste the result.
Enter a value.
config_token> {"access_token":"ya29.a0AeTxxxxxxx1:17:09.3440995+08:00"} ##粘贴一开始获取的access_token
Configure this as a Shared Drive (Team Drive)?

y) Yes
n) No (default)
y/n> ##←←←←←选n
Configuration complete.
Options:
- type: drive
- scope: drive
- token: {"access_token":"xxxxxxxxxxxx"}
- team_drive: 
Keep this "gd" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y  ##←←←←←选y

出现如下则成功完成配置
image-1669292590227

挂载

注:部分CentOS需安装fuse

yum install fuse

创建挂载目录

mkdir data

挂载为本地硬盘

rclone mount Name:/ /root/data --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 --daemon --vfs-cache-mode writes     #name为你一开始输入的name

本文命令:

rclone mount gd:/ /root/data --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 --daemon --vfs-cache-mode writes 

清除挂载

fusermount -qzu /root/data      #qzu后为挂载路径