Ways to Deal with 2FA for PyPI without a Phone

Abstract: Resolve PyPI 2FA issues by replacing insecure SMS verification with TOTP authenticator apps or hardware security keys to prevent SIM swapping attacks.

Created: 2026-08-01 by

You can secure your PyPI account without a phone by generating and storing TOTP (Time-based One-Time Password) secrets using authenticator apps like Google Authenticator or Authy on your mobile device, or by utilizing hardware security keys such as YubiKey. These methods provide robust two-factor authentication while eliminating the dependency on SMS-based verification.

The Problem with SMS-Based 2FA

Two-factor authentication (2FA) is critical for protecting Python package maintainers from unauthorized access to their PyPI accounts. However, relying solely on SMS-based verification presents significant security risks. SIM swapping attacks allow malicious actors to intercept verification codes, bypassing this layer of protection entirely. Furthermore, SMS delivery can be unreliable in areas with poor network coverage, causing delays that hinder deployment workflows. For developers who prioritize security and reliability, moving away from SMS is not just an option but a necessity. The Python Packaging Authority (PyPA) encourages the use of more secure methods that are resistant to interception and do not rely on carrier infrastructure.

Using Authenticator Apps (TOTP)

The most common alternative to SMS is Time-based One-Time Passwords (TOTP). This method generates a six-digit code every 30 seconds based on a shared secret key. To implement this, you first need to enable 2FA on your PyPI account through the settings interface. During the setup process, PyPI will display a QR code or a manual secret key. You should scan this QR code using a trusted authenticator application installed on your smartphone. Popular choices include Google Authenticator, Authy, and Microsoft Authenticator. These apps store the secret locally on your device, ensuring that the codes are generated offline and never transmitted over the network in a vulnerable manner. Once configured, every time you attempt to upload a package using twine or log into the PyPI web interface, you will be prompted for the current code from your app. This adds a strong layer of security because possession of the physical device is required to generate the valid token. It is crucial to keep your backup codes safe. When you enable TOTP, PyPI provides a set of one-time-use backup codes. Store these in a secure password manager or print them out and store them in a physically secure location. If you lose access to your authenticator app, these codes are the only way to recover your account.

Hardware Security Keys (FIDO/U2F)

For users seeking the highest level of security, hardware security keys offer a superior solution. Devices like the YubiKey support FIDO U2F and FIDO2 standards, which are immune to phishing attacks and man-in-the-middle exploits. Unlike TOTP, where codes can potentially be intercepted if a user is tricked into entering them on a fake site, hardware keys verify the domain of the website before allowing authentication. This ensures that you are always interacting with the genuine PyPI server. To use a hardware key, you must register it in your PyPI account settings alongside or instead of other methods. When logging in or uploading packages, you simply touch the button on the key to authenticate. This method is particularly effective for CI/CD pipelines if configured correctly, though it requires careful management of API tokens. Many developers find that the convenience of a single physical object outweighs the initial cost of the hardware key. It eliminates the need to remember or type codes, streamlining the authentication process while enhancing security.

Configuring Twine for Secure Uploads

When deploying packages, you should avoid storing your password in plain text files like .pypirc. Instead, use environment variables or secure credential managers. For TOTP-enabled accounts, twine can prompt for the username and password interactively. Ensure that your development environment does not log sensitive information. If you are automating uploads via GitHub Actions or GitLab CI, use encrypted secrets rather than hardcoding credentials. This practice prevents accidental exposure of your credentials in public repositories or logs. Integrating these security measures protects not only your account but also the integrity of the Python ecosystem. Malicious uploads can compromise thousands of downstream projects. By adopting TOTP or hardware keys, you contribute to a safer environment for all Python developers. Regularly review your active sessions and remove any unrecognized devices or applications. This proactive approach helps identify potential breaches early. Locking User Accounts with Sudo Commands Without Rebooting discusses related system-level security practices that complement your application security strategy. Additionally, understanding Understanding Ubuntu 22.04 VPS Security can help you secure the servers where you build and test your packages, ensuring end-to-end protection.

Best Practices for Maintenance

Regularly update your authenticator app to ensure compatibility with the latest security standards. If you change phones, migrate your TOTP secrets carefully before disposing of the old device. Do not rely on cloud backups of authenticator data unless they are encrypted with a strong passphrase. Consider using a dedicated password manager that supports TOTP generation if you prefer a centralized solution. Always verify the URL when entering codes to prevent phishing. Educate team members about these protocols if you manage multiple maintainers. Consistent adherence to these practices ensures long-term account safety.

Frequently Asked Questions

Can I use 2FA without a smartphone?

Yes, you can use hardware security keys like YubiKey which do not require a smartphone. Alternatively, you can use desktop authenticator software that stores TOTP secrets on your computer, though this is less secure than mobile apps due to malware risks.

What happens if I lose my authenticator app?

If you lose access to your authenticator app, you can use the backup codes provided by PyPI during setup. Each backup code is single-use. If you run out of backup codes, you may need to contact PyPI support to reset your 2FA settings, which could take time.

Is TOTP more secure than SMS?

Yes, TOTP is significantly more secure than SMS. SMS codes can be intercepted via SIM swapping or SS7 network vulnerabilities. TOTP codes are generated locally and expire quickly, making them much harder to exploit without physical access to the device storing the secret.

How do I disable 2FA on PyPI?

You can disable 2FA in your PyPI account settings under the security tab. However, this is strongly discouraged as it leaves your account vulnerable to brute-force attacks. It is better to add additional recovery methods rather than removing 2FA entirely.

Can I use 2FA with CI/CD pipelines?

Yes, but you should use short-lived API tokens instead of passwords. Configure your CI/CD environment to fetch tokens securely from secret management services. Avoid using interactive TOTP prompts in automated scripts; instead, rely on token-based authentication for machine-to-machine communication.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More