Linux安装

预编译的二进制

获取和拆包

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

复制二进制文件

sudo cp rclone /usr/bin/ sudo chown root:root /usr/bin/rclone sudo chmod 755 /usr/bin/rclone

安装手册页

sudo mkdir -p /usr/local/share/man/man1 sudo cp rclone.1 /usr/local/share/man/man1/ sudo mandb

运行rclone config进行设置。有关更多详细信息,请参阅rclone配置文档

rclone config

调整配置

具体流程如下:

配置

驱动器的初始设置需要从Google Drive获取令牌,此操作需在浏览器中完成。rclone config 将引导完成这一过程。

以下是创建名为 remote 的远程连接的示例。首先运行:

rclone config

此指南将引领您完成一个互动式的设置过程:

No remotes found, make a new one? n) New remote r) Rename remote c) Copy remote s) Set configuration password q) Quit config n/r/c/s/q> n name> remote Type of storage to configure. Choose a number from below, or type in your own value [snip] XX / Google Drive \ "drive" [snip] Storage> drive Google Application Client Id - leave blank normally. client_id> Google Application Client Secret - leave blank normally. client_secret> Scope that rclone should use when requesting access from drive. Choose a number from below, or type in your own value 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 Service Account Credentials JSON file path - needed only if you want use SA instead of interactive login. service_account_file> Remote config 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 n) No y/n> y If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth Log in and authorize rclone for access Waiting for code... Got code Configure this as a Shared Drive (Team Drive)? y) Yes n) No y/n> n Configuration complete. Options: type: drive - client_id: - client_secret: - scope: drive - root_folder_id: - service_account_file: - token: {"access_token":"XXX","token_type":"Bearer","refresh_token":"XXX","expiry":"2014-03-16T13:57:58.955387075Z"} Keep this "remote" remote? y) Yes this is OK e) Edit this remote d) Delete this remote y/e/d> y

请参阅远程设置文档,了解如何在没有互联网浏览器的机器上进行设置。

请注意,如果使用网页浏览器进行自动身份验证,rclone 会在您的本地机器上运行一个网络服务器,以收集 Google 返回的令牌。此服务器仅在打开您的浏览器至您获取验证码的这段时间内运行。此服务器位于 http://127.0.0.1:53682/,如果您正在运行主机防火墙,可能需要暂时解除对其的阻止,或者使用手动模式。

然后,您可以按以下方式使用它:

列出驱动器顶级目录中的目录

rclone lsd remote:

列出驱动器中的所有文件

rclone ls remote:

将本地目录复制到名为 backup 的驱动器目录中

rclone copy /home/source remote:backup

由于Rclone 会在服务器的53682端口验证Google Drive账号,直接在服务器打开不了验证链接,需要从本地进行打开

解决无法在服务器打开网址的问题:使用 SSH 端口转发

设置 SSH 端口转发:

  1. 在本地计算机上打开一个新的终端窗口
  2. 运行以下命令建立 SSH 隧道:

bash

ssh -L 53682:127.0.0.1:53682 root@your ip(服务器IP)
  1. 保持此窗口打开
  2. 在服务器上重新运行 rclone 授权命令
  3. 这次,在本地浏览器中直接使用 http://127.0.0.1:53682/auth?state=… 链接进行谷歌的网盘鉴权。

检查 Google Drive 配置是否成功

1. 列出已配置的远程存储

bash

rclone listremotes

如果看到 gdrive: 或您之前配置的名称出现在列表中,则表示基本配置已存在。

2. 检查 Google Drive 详细信息

这里的gdrive只是示例

bash

rclone about gdrive:

这会显示 Google Drive 存储信息,包括总空间和已用空间。如果命令成功执行,表示连接正常。

3. 列出 Google Drive 内容

bash

rclone ls gdrive:

这会列出 Google Drive 根目录中的文件和文件夹。如果能看到文件列表,则配置无疑是成功了