说明:Linux服务器上下载了好多资源。但是Linux没有onedrivegoogle drive的客户端。那么如何把vps上的文件传到onedrive呢。这里我们可以用rclone这个工具。

安装Rclone

第一步:下载windows对应位数的压缩包

解压到D:\rclone

管理员命令提示符(cmd)输入下面的命令,回车

cd /d d:\rclone
rclone authorize "onedrive"

会自动打开浏览器让你登录你的onedrive账户
点击授权后浏览器显示如图
回到cmd,发现多了一大串字符。复制花括号里的所有字符,新建一个文档保存,一会要用。

第二步:开始配置Linux端

打开你的SHH工具连接vps,我的是debian系统,输入:

apt-get update
apt-get install -y unzip fuse

然后输入:

wget https://downloads.rclone.org/rclone-current-linux-amd64.zip
unzip rclone-current-linux-amd64.zip
chmod 0777 ./rclone-*/rclone
cp ./rclone-*/rclone /usr/bin/
rm -rf ./rclone-*

然后输入:

rclone config

即可调出配置信息

第三步:新建

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> 

输入n
显示如下
name>
这里我们起个名字

第四步:出现一堆网盘序号

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 / 1Fichier
   \ "fichier"
 2 / Alias for an 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 / Citrix Sharefile
   \ "sharefile"
 9 / Dropbox
   \ "dropbox"
10 / Encrypt/Decrypt a remote
   \ "crypt"
11 / FTP Connection
   \ "ftp"
12 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
13 / Google Drive
   \ "drive"
14 / Google Photos
   \ "google photos"
15 / Hubic
   \ "hubic"
16 / In memory object storage system.
   \ "memory"
17 / JottaCloud
   \ "jottacloud"
18 / Koofr
   \ "koofr"
19 / Local Disk
   \ "local"
20 / Mail.ru Cloud
   \ "mailru"
21 / Mega
   \ "mega"
22 / Microsoft Azure Blob Storage
   \ "azureblob"
23 / Microsoft OneDrive
   \ "onedrive"
24 / OpenDrive
   \ "opendrive"
25 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
26 / Pcloud
   \ "pcloud"
27 / Put.io
   \ "putio"
28 / QingCloud Object Storage
   \ "qingstor"
29 / SSH/SFTP Connection
   \ "sftp"
30 / Sugarsync
   \ "sugarsync"
31 / Transparently chunk/split large files
   \ "chunker"
32 / Union merges the contents of several remotes
   \ "union"
33 / Webdav
   \ "webdav"
34 / Yandex Disk
   \ "yandex"
35 / http Connection
   \ "http"
36 / premiumize.me
   \ "premiumizeme"
Storage>

找到对应的序号,我这里onedrive是23号。
输入23回车

第五步:接下来

** See help for onedrive backend at: https://rclone.org/onedrive/ **

Microsoft App Client Id
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_id> 

默认空着,直接回车

Microsoft App Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret> 

默认空着,直接回车
Microsoft App Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret> 
Edit advanced config? (y/n)
y) Yes
n) No (default)
y/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 (default)
n) No
y/n>

选择n
For this to work, you will need rclone available on a machine that has a web browser available.
Execute the following on your machine (same rclone version recommended) :
        rclone authorize "onedrive"
Then paste the result below:
result>

这里我们输入刚才复制的一大堆字符串
Choose a number from below, or type in an existing value
 1 / OneDrive Personal or Business
   \ "onedrive"
 2 / Root Sharepoint site
   \ "sharepoint"
 3 / Type in driveID
   \ "driveid"
 4 / Type in SiteID
   \ "siteid"
 5 / Search a Sharepoint site
   \ "search"
Your choice>

这里输入1

Found 1 drives, please select the one you want to use:
0: OneDrive (business) id=b!5aaxzEKnQ0moUdSJN5FFiz18jOg3bKJDpnlLne7FeEjh0fnzsP3TSIpazFa4zHn9
Chose drive to use:>

这里显示出来了网盘序号,输入0
Found drive 'root' of type 'business', URL: https://ememe-my.sharepoint.com/personal/admin_ememe_onmicrosoft_com/Documents
Is that okay?
y) Yes (default)
n) No
y/n> 

配置好了。输入y

drive_id = b!5aaxzEKnQ0moUdSJN5FFiz18jOg3bKJDpnlLne7FeEjh0fnzsP3TSIpazFa4zHn9
drive_type = business
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d

到这里我就就已经配置完成,输入y
然后就没事了。输入q退出rclone就行

第六步:别忘了还需要安装个screen

apt-get install -y screen    //这是debian系

centos系安装screen需要使用yum install screen

上传命令

rclone move source:path dest:path    //别急看完下面的

screen rclone move /root/download onedrive1:/upload --transfers 32 -P    //完整的命令

参数详解:

source:path是本地目录,dest:path是云端目录

其中dest是网盘名称,就你刚才随便取的那个path就是目录

你可以指定上传到哪一个文件夹

比如说,

我要把本地的/root/download目录下所有的文件移动到onedrive里面的/upload文件夹里面

命令应该是rclone move /root/download onedrive1:/upload

但是这样上传的话,他一直在前台上传,占用你的ssh。
想让他变成后台,在前面加上screen

命令就是:screen rclone move /root/download onedrive1:/upload

这样你就可以关掉ssh,他就可以在后台上传

如果文件目录比较复杂,而且文件数量庞大
可以提高线程,他默认是4线程,测试后发现100M带宽32线程效果最好。(根据你的vps而定线程。)

可以在后面再加一个参数 -P(大写)显示上传详情

screen rclone move /root/download onedrive1:/upload –transfers 32 -P

screen
等你想看看传完了没有的时候,
screen -ls就可以看到后台screen进程。

配置Google Drive盘

google drive盘有区分个人盘团队盘

1.配置

这里我们先配置个人盘,团队盘也同理。

  1. 输入 rclone config
  2. 输入 n
  3. 提示如下:
  4. 给本次配置的网盘起个名字
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> n
name> 
这网盘起个名字
12 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
13 / Google Drive
   \ "drive"
14 / Google Photos
   \ "google photos"
   选择13
** See help for drive backend at: https://rclone.org/drive/ **

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> 
空着就行,回车
建议:会搞得,强烈建议用自己的私有API,效率会大大增加
Google Application Client Secret
Setting your own is recommended.
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.

Note that if this is blank, the first time rclone runs it will fill it
in with the ID of the root folder.

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.
Enter a string value. Press Enter for the default ("").
service_account_file> 
空着,回车
Service Account Credentials JSON file path 
Leave blank normally.
Needed only if you want use SA instead of interactive login.
Enter a string value. Press Enter for the default ("").
service_account_file> 
Edit advanced config? (y/n)
y) Yes
n) No (default)
y/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 (default)
   n) No
   y/n> 
   输入n
Please go to the following link:

https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id20264815644.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awgoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=kXGnW8AtxDZinUY7auTP9w

Log in and authorize rclone for access
Enter verification code> 
把提示的这个连接放到浏览器打开


授权允许,出现这个代码,复制粘贴到SSH工具,回车

Configure this as a team drive?
y) Yes
n) No (default)
y/n>
注意注意注意,配置个人盘就输入n,配置团队盘输入y
[google_hy]
type = drive
scope = drive
token = {"access_token":"ya29.Il-9B-x15fy1sfTMSML-MkqVgTq2W0W_VVqluwoWXuioeglrF-LnjinhMGDyqa0HDk0SYTvXkAMZviYx2yM40AnMl4IK-3QhAf1FE54X2hVOiIuDpiRsU3oClksw","token_type":"Bearer","refresh_token":"1//03ztJYkqbqDnuCgYIARAAGAMSNwF-L9IrKCRqVpsgKMqWSa0an_uMblaHiJS-FPCB9T6lGj2taVQ0U7og5m3z1FOuC-UlNDJL204","expiry":"2020-02-07T14:13:26.261934522Z"}

team_drive = 0ANzkcvxKCBWaUk9PVA
--------------------

y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> 
到这里就完成个人盘的配置了。

2.上传

还需要安装个screen

apt-get install -y screen

上传命令

screen rclone move /1/aria2/ onedrive_rive:/upload --transfers 32 -P

美团新老用户点击送5/9话费充值卷/不限制老用户每月都可以必中 【点击查看】。
最后修改:2020 年 10 月 04 日 07 : 41 PM
如果觉得我的文章对你有用,请随意赞赏