Rclone is a command line program to sync files and directories to and from kinds of cloud file storage and synchronization service.
Since 12th September 2017, the Rclone have supported the “OneDrive for Business” and covered the main cloud storages. Thanks to the developers!
I will introduce how to config the “OneDrive for Business”, that need to authorize by browser, on the command line interface.
There are two method to finish the process.
- Configure on local machine first and copy the config file to vps.
The path of config file on Windows:C:\Users\***\.config\rclone\rclone.conf
The path of config file on Linux:~/.config/rclone/rclone.conf
- Use the Ngrok to forward the traffic of local port, that is listened to rclone.
Install Rclone
123curl -O https://downloads.rclone.org/rclone-current-linux-amd64.zipunzip rclone-current-linux-amd64.zipcd rclone-*-linux-amd64Set Up Ngrok
12345wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zipunzip ngrok-stable-linux-amd64.zip./ngrok authtoken 6c4SjM****************7FqEG8Roscreen -S ngrok./ngrok http 53682The Rclone will listen the 53682 port when configuring the “OneDrive for Business”. After run the commands, you can see the ngrok link have forwarded the 53682 port. Record the ngrok link. Press Ctrl+A+D to quit the “screen” or open a new terminal.
Rclone Config
Follow the steps until “Waiting for code…”.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667$ ./rclone config2017/11/30 05:19:11 NOTICE: Config file "/home/ubuntu/.config/rclone/rclone.conf" not found - using defaultsNo remotes found - make a new onen) New remotes) Set configuration passwordq) Quit confign/s/q> nname> onedriveType of storage to configure.Choose a number from below, or type in your own value1 / Amazon Drive\ "amazon cloud drive"2 / Amazon S3 (also Dreamhost, Ceph, Minio)\ "s3"3 / Backblaze B2\ "b2"4 / Box\ "box"5 / Dropbox\ "dropbox"6 / Encrypt/Decrypt a remote\ "crypt"7 / FTP Connection\ "ftp"8 / Google Cloud Storage (this is not Google Drive)\ "google cloud storage"9 / Google Drive\ "drive"10 / Hubic\ "hubic"11 / Local Disk\ "local"12 / Microsoft Azure Blob Storage\ "azureblob"13 / Microsoft OneDrive\ "onedrive"14 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)\ "swift"15 / QingClound Object Storage\ "qingstor"16 / SSH/SFTP Connection\ "sftp"17 / Yandex Disk\ "yandex"18 / http Connection\ "http"Storage> 13Microsoft App Client Id - leave blank normally.client_id>Microsoft App Client Secret - leave blank normally.client_secret>Remote configChoose OneDrive account type?* Say b for a OneDrive business account* Say p for a personal OneDrive accountb) Businessp) Personalb/p> bUse auto config?* Say Y if not sure* Say N if you are working on a remote or headless machiney) Yesn) Noy/n> yIf your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/authLog in and authorize rclone for accessWaiting for code...
You can get the authorization link “http://127.0.0.1:53682/auth”.
Change “127.0.0.1:53682” to “b16e00cf.ngrok.io”, that forwards the local port “53682“.
Visit the “http://b16e00cf.ngrok.io/auth”. Login the office 365 account and authorize. You can get the responce link like this:
1http://localhost:53682/?code=AQABAAIAA************LV38WMZ3MFwgAA&state=02c7978fa9c1a8262125b50ee8334b6b&session_state=22f15d*****48c1b11
Also, Change “127.0.0.1:53682” to “b16e00cf.ngrok.io”. Visit the changed link on browser to finish authorization.
1http://b16e00cf.ngrok.io/?code=AQABAAIAA************LV38WMZ3MFwgAA&state=02c7978fa9c1a8262125b50ee8334b6b&session_state=22f15d*****48c1b11
123456789101112131415161718192021222324252627Got code2017/11/30 05:27:17 NOTICE: Found API v2.0 endpoint https://pyoffice-my.sharepoint.com/_api/v2.0/me--------------------[onedrive]client_id =client_secret =token = {"access_token":"********.*****xpiry":"2017-11-30T06:27:13.508653552Z"}resource_url = https://pyoffice-my.sharepoint.com/--------------------y) Yes this is OKe) Edit this remoted) Delete this remotey/e/d> yCurrent remotes:Name Type==== ====onedrive onedrivee) Edit existing remoten) New remoted) Delete remoter) Rename remotec) Copy remotes) Set configuration passwordq) Quit confige/n/d/r/c/s/q> q
Thanks, solved my issue!