改版后的新版GCP界面通过AutoRclone批量生成SA文件的究极保姆级教程

本文更新于2021.7.15。

准备工作:一台能访问Google的VPS。本文所使用的VPS环境为DigitalOcean的Ubuntu 20.04。

Debian 9+,Centos 7+ 理论可行,但未测试。

DigitalOcean注册地址:https://m.do.co/c/76209bc8b100 (注册即可获得100刀的额度,可使用60天)

前言:自从GCP页面更改后,之前生成SA的教程都已失效,于是做一个教程帮助大家(本人能力有限,教程中难免有错误,还请各位谅解并指正)

更改后的GCP授权页面

教程正式开始:

一. 创建项目并获取相关授权文件

2. 第一次进入这个界面会弹出如上图的欢迎界面,同意之后点击同意并继续。

此时,已经创建好了一个全新的项目,我们继续。

4. 开启相关API

一般情况下需要开启如下5个API

Google Drive API
Identity and Access Management (IAM) API
Service Usage API
Cloud Resource Manager API
IAM Service Account Credentials API

我只示例Google Drive API开启具体步骤,其余API步骤相同:

稍等片刻,Google Drive API就启动成功了。

然后点击左上角三条横线,找到 API与服务-库 搜索其余4个API并开启。(有的默认开启的就不用管了)

操作完成后,我们检验一下是否全部开启成功,

确认5个API开启后,我们进行下一步

至此,OAuth同意屏幕配置完成,接下来创建客户端ID和密码

到此,我们成功获得了授权文件。

二、 通过AutoRclone项目创建SA

接下来需要到VPS上操作了,首先远程登陆好你的VPS。

  1. 配置环境

Ubuntu、Debian:

apt-get update && apt-get upgrade -y
apt-get install wget curl python3 python3-pip git unzip screen sudo fuse -y

Centos:

yum -y update
yum install epel-release -y
yum install wget curl python3 python3-pip git screen unzip sudo fuse fuse-devel -y 

安装完成后,试试输入 python -V或者 python3 -V看看有没有反应,如果有说明 python 配置正确,请继续下一步;如果没有,请自行配置 python 环境。

2. 安装Node.js

Debian:

curl -sL https://deb.nodesource.com/setup_12.x | bash -
apt-get install -y nodejs

Ubuntu:

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
apt-get install -y nodejs

Centos:

curl -sL https://rpm.nodesource.com/setup_lts.x | bash -
yum install -y nodejs
yum install gcc-c++ make
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo
yum install yarn

安装好之后输入node -v,如果输出的是Node.js的版本号,则表示Node.js配置正确,若输出错误请自行配置Node.js环境

3. 安装rclone、AutoRclone

Centos:

cd && curl https://rclone.org/install.sh | sudo bash
sudo git clone https://github.com/xyou365/AutoRclone && cd AutoRclone && sudo pip3 install -r requirements.txt

Ubuntu、Debian:

sudo apt-get install screen git && curl https://rclone.org/install.sh | sudo bash
sudo git clone https://github.com/xyou365/AutoRclone && cd AutoRclone && sudo pip3 install -r requirements.txt

4. 将刚下载好的授权文件上传到AutoRclone根目录

上传可以使用宝塔面板或者xftp,这个不会的可以自行谷歌,

https://www.google.com/search?q=ssh%E4%B8%8A%E4%BC%A0%E6%96%87%E4%BB%B6

上传完成后继续操作,

5. 生成SA

cd && cd /root/AutoRclone
python3 gen_sa_accounts.py --quick-setup 1 --new-only

我们可以执行 ls /root/AutoRclone/accounts ,发现里面有100个SA授权文件,至此SA已生成完毕。

温馨提示:SA授权文件非常重要,建议下载保存,丢失找回非常困难!

最后更新于