Free2FA4RDG is a free solution for enabling two-factor authentication when using Remote Desktop (RDP) through the Windows Server RD Gateway service. This system uses a Telegram bot as the second factor for authentication, providing an additional layer of security.
Версия на русском
- RD Gateway: A service that allows secure connection to a desktop through a VPN-like connection.
- Network Policy Server (NPS): Receives requests from the RD Gateway and redirects them to the Free2FA4RDG component.
- Free2FA4RDG: Processes authentication requests using the Telegram bot.
Free2FA4RDG consists of several microservices, each performing a specific role within the two-factor authentication system:
This service is responsible for initial setup and pre-configuration of the system. It includes the generation and management of certificates necessary for the secure operation of other system components.
This service provides a web interface for administrative management of the system.
An API service for the administrative interface, ensuring interaction between the web interface and the server part of the system.
The main API service, handling authentication requests and interacting with the Telegram bot for user login confirmation.
FreeRADIUS is used in free2fa4rdg. FreeRADIUS is free software and is distributed under GNU General Public License version 3 (GPL-3.0). FreeRADIUS official website: https://freeradius.org/ We use FreeRADIUS with no changes to the source code, only with configuration tweaks to meet the requirements of our project. This component includes a FreeRADIUS server, processing RADIUS requests from the NPS (Network Policy Server) and forwarding them for processing in free2fa4rdg_api.
Each of these services operates in its own Docker container, ensuring modularity and simplifying the scaling of the system.
The installation script has been tested on Ubuntu 22.04 LTS and CentOS 7. However, as this is a Docker Compose-based setup, it can, in principle, be deployed manually on any Linux system that supports Docker and is compatible with x86 and x64 architectures. This flexibility is due to Docker's containerization technology, which allows the application to run consistently across different Linux distributions as long as Docker and Docker Compose are available.
- The user connects to RDP through the RD Gateway.
- The RD Gateway forwards the request to the NPS.
- The NPS requests the second factor of authentication from Free2FA4RDG.
- Free2FA4RDG sends a confirmation request to the user's Telegram application.
- The user confirms the login through Telegram and gains access to RDP.
- Registration in Telegram and creation of a bot to obtain an authorization token.
- Presence of installed and configured Remote Desktop Gateway and Network Policy and Access Service components on Windows Server.
- A server with Docker Compose, accessible on UDP port 1812 for NPS and on port 443 for the administrative panel.
- Access to
api.telegram.org
andhub.docker.com
.
- Create a new Telegram bot: https://core.telegram.org/bots#creating-a-new-bot.
- Install Linux, selecting Ubuntu 22.04 LTS or CentOS 7 (tested on these versions).
- Create a directory for Free2FA4RDG settings:
mkdir -p /opt/2fa/ && cd /opt/2fa/
- Run the installation script:
curl -o install.sh https://raw.githubusercontent.com/CLLlAgOB/free2fa4rdg/main/install.sh && bash install.sh
- Follow the script instructions.
- Create a dns entry for the admin portal (https://free2fa4rdg_admin_html by default) or the name you specified in the ADDITIONAL_DNS_NAME_FOR_ADMIN_HTML parameter. Default password and login for the admin portal: admin admin.
- Create a new group in the Remote RADIUS Server Groups section:
- Group name:
free2fa4rdg
- Server: IP address of the Linux server.
- Shared secret: Your secret, which will be in the .env file (
RADIUS_CLIENT_SECRET
). - Load Balancing: set timeouts to 60 seconds each
- Group name:
- In the Connection Requests Policies, open the properties of the
TS GATEWAY AUTHORIZATION POLICY
policy and setForward requests to the following remote RADIUS server group for authentication: free2fa4rdg
.
CA_EXPIRY_DAYS
: Certificate validity period, in days.FREE2FA_TELEGRAM_BOT_TOKEN
: Your Telegram bot token.FREE2FA_TELEGRAM_BOT_LANGUAGE
: Language model (ru or en).FREE2FA_AUTO_REG_ENABLED
: Automatic registration of new users. (New users will be automatically created in the database with Telegram ID 0, the real ID needs to be specified in the admin portal.)FREE2FA_BYPASS_ENABLED
: (true/false) Bypass users without request with Telegram ID 0.RADIUS_CLIENT_SECRET
: Secret phrase for RADIUS.FREE2FA_TIMEOUT
: Waiting time for login confirmation (from 10 to 20).RADIUS_START_SERVERS
: Number of initial RADIUS server processes.RADIUS_MAX_SERVERS
: Maximum number of RADIUS server processes.RADIUS_MAX_SPARE_SERVERS
: Maximum number of backup RADIUS server processes.RADIUS_MIN_SPARE_SERVERS
: Minimum number of backup RADIUS server processes.ADMIN_SECRET_KEY
: Administrator key (generated if left empty).RESET_PASSWORD
: Enabling password reset function (to reset, you will need to specify ADMIN_SECRET_KEY).ALLOW_API_FAILURE_PASS
: (true/false) Allow users to pass without 2FA ifapi.telegram.org
is unavailable.ADDITIONAL_DNS_NAME_FOR_ADMIN_HTML
: DNS name of the admin website. It needs to be specified in DNS or hosts for convenient access.
You will need to change your administrator password the first time you log in.