Log in to Linux via Discord (cursed)
Caution
Do not actually use this for anything important. This is not intended to be a secure way to log in.
For Debian and its derivatives, you will need to install libpam0g-dev
to compile the PAM module.
You will also need to have Bun installed to be able to compile the discord authentication binary. After it's installed, run bun install
to install the dependencies.
- Create a new application on the Discord Developer Portal.
- Go to the "Bot" tab, create a bot for the application, and copy its token.
- In the file "env.h" paste the Discord bot token inside the parentheses in the line containing "DISCORD_TOKEN".
- Go to the "Installation" tab and change the authorization method from "Guild Install" to "User Install". Then, set the install link to "Discord Provided Link" and open the link in your browser to authorize the bot.
- In your Discord app, go to Advanced settings and turn on developer mode. Then, exit settings, click your name in the bottom left, then click "Copy User ID".
- In the file "env.h", paste the user id inside the parenthese in the line containing "DISCORD_APPROVER_USER_ID".
- Go to /etc/pam.d/ and edit the file "login" with administrative privileges. You may want to make a copy of the file before you do this as a backup. At the bottom of the file, add the line
auth required pam_jam.so
. This will make the PAM module required for login. - Confirm that the file "pam_deny.so" is in the directory '/lib/x86_64-linux-gnu/security/'. If it is somewhere else, you will need to change the paths in build.sh and env.h to the correct location.
- Run
build.sh
to compile and copy the binaries to the correct location. - Try logging in. You should receive a DM from the Discord bot that will allow you to approve or decline the login request.