如何为Nextcloud启动二次验证中的Telegram验证码

Nextcloud其实还是挺好弄的,它甚至可以兼容v2,表面上是个网盘实际上后面是一个代理。

https://nextcloud-twofactor-gateway.readthedocs.io/en/stable/Admin%20Documentation/

这是官方的教程,咋一看特别的语焉不详,关键就出在Nextcloud的occ,occ是Nextcloud官方推出的一种命令行一样的东西,本意是快速设置一些功能,但是不知道为什么没做进去网页GUI里,总之就搞得刚接触Nextcloud的人对occ一脸懵逼了。

总之先

cd /var/www/html/nextcloud

这条命令是定位到Nextcloud路径所在地。一般的Nextcloud教程都是让你安装到这个路径的。

然后如果你现在ls一下你会看见有一个叫occ的玩意躺在Nextcloud的文件夹里,那么那个东西是怎么调用的呢?

在Ubuntu/Debian里面,直接

sudo -u www-data php occ twofactorauth:gateway:configure telegram

其实中文还是有非常多关于occ的教程的,这个倒是不难找到,只是要在官方的前面加上一些sudo啊php啊什么的前缀就是了。

然后接下来跟着官方的教程去Telegram注册bot就好了。

This gateways allows you to send messages via the Telegram protocol. In order to send messages, you have to register a Telegram Bot, which is used to send authentication codes to users after they have initiated a conversation and entered their Telegram ID.

Follow these steps to activate the Telegram authentication gateway:

Register a Telegram Bot.

Open your Telegram client, search for @BotFather and start a conversation.

Send /newbot to start the bot setup process.

Send the name of the bot, e.g. ‘My own NC bot’.

Send the username of the bot, e.g. ‘my_nc_bot’.

BotFather confirms that a new bot has successfully been set-up and provides the HTTP API access token to you, e.g. ‘123456789:AAbbCCddEEffGGhhIIjjKKllMMnnOOppQQ’.

Activate the Nextcloud Twofactor Gateway for Telegram Open a command shell on your Nextcloud server, navigate to the Nextcloud directory and run the following command: bash occ twofactorauth:gateway:configure telegram Please enter your Telegram bot token: 123456789:AAbbCCddEEffGGhhIIjjKKllMMnnOOppQQ Using 123456789:AAbbCCddEEffGGhhIIjjKKllMMnnOOppQQ.

The Telegram authentication gateway has now successfully been set-up. Follow the instructions in the User Documentation to activate the Gateway for a specific user.