###### tags: `私有文章` # rclone 配置方式 ###### 目錄 - [OneDrive 部分](#OneDrive-部分) - [Google Drive 部分](#Google-Drive-部分) - [加密配置檔](#加密配置檔) ------- 1. 首先打開 cmd,`cd` 到 rclone.exe 檔案目錄下,然後輸入 ``` rclone config --config=./rclone.conf ``` ## OneDrive 部分 接著比照以下輸入,如遇欲輸入項,但我這裡是為空白的。即為 [Enter] 就可以了。 如果明白某項的作用,也可以自己設定該項的配置。 ``` C:\Users\jimmy\Desktop>rclone config --config=./rclone.conf No remotes found - make a new one n) New remote s) Set configuration password q) Quit config n/s/q> n name> onedrive 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 . . . 15 / Google Drive \ "drive" 16 / Google Photos \ "google photos" . . . 26 / Microsoft OneDrive \ "onedrive" . . . Storage> 26 OAuth Client Id Leave blank normally. Enter a string value. Press Enter for the default (""). client_id> OAuth Client Secret Leave blank normally. Enter a string value. Press Enter for the default (""). client_secret> Choose national cloud region for OneDrive. Enter a string value. Press Enter for the default ("global"). Choose a number from below, or type in your own value 1 / Microsoft Cloud Global \ "global" 2 / Microsoft Cloud for US Government \ "us" 3 / Microsoft Cloud Germany \ "de" 4 / Azure and Office 365 operated by 21Vianet in China \ "cn" region> 1 Edit advanced config? y) Yes n) No (default) y/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> y 2022/03/21 17:13:09 NOTICE: If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=qyXEs2bRjY297QgHITV3Xw 2022/03/21 17:13:09 NOTICE: Log in and authorize rclone for access 2022/03/21 17:13:09 NOTICE: Waiting for code... 2022/03/21 17:13:12 NOTICE: Got code Type of connection Enter a string value. Press Enter for the default ("onedrive"). Choose a number from below, or type in an existing value 1 / OneDrive Personal or Business \ "onedrive" 2 / Root Sharepoint site \ "sharepoint" 3 / Sharepoint site name or URL (e.g. mysite or https://contoso.sharepoint.com/sites/mysite) \ "url" 4 / Search for a Sharepoint site \ "search" 5 / Type in driveID (advanced) \ "driveid" 6 / Type in SiteID (advanced) \ "siteid" 7 / Sharepoint server-relative path (advanced, e.g. /teams/hr) \ "path" config_type> 1 Drive OK? Found drive "root" of type "business" URL: https://cotpear-my.sharepoint.com/personal/yi_cotpear_com/Documents y) Yes (default) n) No y/n> y -------------------- [onedrive] type = onedrive token = {"access_token":"[私密內容]"} drive_id = [私密內容] drive_type = business -------------------- y) Yes this is OK (default) e) Edit this remote d) Delete this remote y/e/d>y Current remotes: Name Type ==== ==== onedrive onedrive ``` ## Google Drive 部分 ``` Current remotes: Name Type ==== ==== onedrive onedrive 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> e/n/d/r/c/s/q> n name> google_drive 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 . . . 15 / Google Drive \ "drive" 16 / Google Photos \ "google photos" . . . 26 / Microsoft OneDrive \ "onedrive" . . . Storage> 15 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 string value. Press Enter for the default (""). client_id> OAuth Client Secret Leave blank normally. Enter a string value. Press Enter for the default (""). client_secret> Scope that rclone should use when requesting access from drive. Enter a string value. Press Enter for the default (""). 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 ID of the root folder Leave blank normally. Fill in to access "Computers" folders (see docs), or for rclone to use a non root folder as its starting point. Enter a string value. Press Enter for the default (""). root_folder_id> 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 string value. Press Enter for the default (""). service_account_file> Edit advanced config? y) Yes n) No (default) y/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> 2022/03/21 17:21:13 NOTICE: If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=8GfxZ03ML9uRZl1Q95DVCg 2022/03/21 17:21:13 NOTICE: Log in and authorize rclone for access 2022/03/21 17:21:13 NOTICE: Waiting for code... 2022/03/21 17:21:25 NOTICE: Got code Configure this as a Shared Drive (Team Drive)? y) Yes n) No (default) y/n> -------------------- [google_drive] type = drive scope = drive token = {"access_token":"[私密部分]"} team_drive = -------------------- y) Yes this is OK (default) e) Edit this remote d) Delete this remote y/e/d> y Current remotes: Name Type ==== ==== google_drive drive onedrive onedrive 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 C:\Users\jimmy\Desktop> ``` ## 加密配置檔 ### 為甚麼要加密配置檔 因為 Github repo 是公開的,如果沒加密配置檔,會致您的帳戶和檔案於水深火熱之中。 ### 步驟 1. 安裝 [GPG4Win](https://gpg4win.org/thanks-for-download.html),重開機。 2. 輸入以下指令(在 `rclone.conf` 目錄下): ``` gpg --symmetric --cipher-algo AES256 rclone.conf ``` 3. 依照提示設定加密密碼。 4. 將 `rclone.conf.gpg` 檔案上傳到 repository 的主目錄(`/`) 5. 到 Repository Setting 網頁,進入 'Security' > 'Action' > [New repository secret]。![](https://i.imgur.com/Zbmt9IA.png) 6. [Name] 輸入 `GPG_PASSPHRASE`,[Value] 輸入 `剛剛加密時設定的密碼`。最後按 [Add secret]。![](https://i.imgur.com/S612J2G.png) 完畢 > 本文保留一切智慧財產權權利,轉載請註明出處「Yi Chi」 及本文網址。