How to Use aria2c with NTLM Authentication on Ubuntu
This guide explains how to configure the aria2c command-line utility to download files from servers that require NTLM authentication on Ubuntu. You will learn the necessary flags to pass your credentials securely and execute the download without errors. By following these steps, you can automate file transfers from corporate intranets or protected repositories efficiently.
Install aria2
Open your terminal and ensure your package list is updated. Install aria2 using the apt package manager with the following command:
sudo apt update
sudo apt install aria2Execute the Download Command
To download a file from a server requiring NTLM authentication, you must specify your username, password, and enable the authentication challenge flag. Use the following syntax structure:
aria2c --http-user="YOUR_USERNAME" --http-passwd="YOUR_PASSWORD" --http-auth-challenge=true "URL_TO_FILE"Replace YOUR_USERNAME and YOUR_PASSWORD
with your actual credentials. Replace URL_TO_FILE with the
direct link to the resource you wish to download. The
--http-auth-challenge=true option is critical for NTLM as
it forces aria2c to wait for the server’s authentication challenge
before sending credentials.
Secure Your Credentials
Avoid typing passwords directly into the terminal command history. Instead, use environment variables to pass sensitive data. Export your credentials before running the download command:
export ARIA2_USER="YOUR_USERNAME"
export ARIA2_PASS="YOUR_PASSWORD"
aria2c --http-user="$ARIA2_USER" --http-passwd="$ARIA2_PASS" --http-auth-challenge=true "URL_TO_FILE"This method prevents your password from being saved in your bash history file. Once the download is complete, unset the variables to clear them from the current session memory.
unset ARIA2_USER
unset ARIA2_PASSVerify the Download
Check your current directory to confirm the file exists. You can list
the most recently modified files using the ls command:
ls -lt | headIf the download failed, verify that your network connection allows access to the server and that your credentials have the necessary permissions. Ensure you are using the correct URL, as some NTLM servers require specific endpoint paths.