This repo provides a helper script (avd.sh) that connects to Azure Virtual Desktop (AVD) from Linux using FreeRDP 3 (sdl-freerdp3), while using Firefox for CAC-based sign-in.
It automates:
- launching FreeRDP with the right AVD/Gov flags
- opening Firefox to the AAD sign-in URL
- prompting you to paste the final redirect URL(s) back into FreeRDP (some tenants require 2 redirects)
Reality check: Entra ID sign-in is a web/OAuth flow. This script doesn’t remove the browser step; it makes it less painful.
- A
.rdpwfile for your AVD Desktop/App (downloaded from your AVD portal). - Recommended locations:
~/avd/~/Downloads/
The script will auto-select the newest *.rdpw it finds in those locations if you don’t specify a file.
- CAC reader + CAC card
- FreeRDP 3 with
sdl-freerdp3 expectfirefox- PC/SC smartcard stack (
pcscd, CCID driver, OpenSC)
sudo pacman -Syu
sudo pacman -S freerdp expect firefox pcsc-lite ccid opensc pcsc-tools
sudo systemctl enable --now pcscdVerify the reader:
pcsc_scanMany Debian/Ubuntu releases ship FreeRDP 2.x by default. You need FreeRDP 3.x (with
sdl-freerdp3). Ifsdl-freerdp3is not available in your repos, you may need a newer repo/backport or to build FreeRDP 3.x.
Typical smartcard dependencies:
sudo apt update
sudo apt install -y expect firefox pcscd opensc pcsc-tools libccid
sudo systemctl enable --now pcscdsudo dnf install -y freerdp expect firefox pcsc-lite pcsc-lite-ccid opensc pcsc-tools
sudo systemctl enable --now pcscdDownload the .rdpw for your desktop/app from your AVD portal.
If you have multiple desktops/regions, you may end up with multiple .rdpw files (e.g., Army Desktop.rdpw, Army Desktop(1).rdpw, etc.). The script includes a --list option to make this manageable.
- Put the script somewhere convenient:
mkdir -p ~/avd
cp avd.sh ~/avd/avd.sh
chmod +x ~/avd/avd.sh- Put your
.rdpwin one of:
~/avd/(recommended)~/Downloads/
- Set your identity (recommended: UPN) in your shell profile.
export AVD_UPN="first.m.last.mil@army.mil"Reload:
source ~/.zshrcAlternative (if you prefer the exact FreeRDP username format):
export AVD_USER=".\AzureAD\\first.m.last.mil@army.mil"Use either
AVD_UPNorAVD_USER.
~/avd/avd.sh --listOutput is grouped by tenantId and highlights the newest file per tenant in green.
~/avd/avd.sh --print-config~/avd/avd.sh~/avd/avd.sh "$HOME/avd/Army Desktop.rdpw"MAX_REDIRECTS=5 ~/avd/avd.shRDPW="$HOME/avd/Army Desktop(2).rdpw" ~/avd/avd.sh- FreeRDP prints a “Browse to:” URL.
- The script opens Firefox (private window) to that URL.
- Complete CAC sign-in in Firefox.
- Copy the final redirect URL from the address bar (it must contain
?code=...) and paste it into the terminal when prompted. - Sometimes FreeRDP asks for a second redirect. Repeat the copy/paste.
- Confirm
pcscdis running:systemctl status pcscd
- Replug the reader / try another USB port.
- Confirm CCID package is installed:
- Arch:
ccid - Debian/Ubuntu:
libccid - Fedora:
pcsc-lite-ccid
- Arch:
- Ensure OpenSC is installed (
opensc). - If needed, add the PKCS#11 module in Firefox:
- Settings → Privacy & Security → Certificates → Security Devices → Load
- Common module path:
/usr/lib/opensc-pkcs11.so(path varies)
This script enables smartcard redirection (/smartcard), but the remote host pool must also allow it.
Inside the AVD session, verify:
- Device Manager → Smart card readers
certmgr.mscshows CAC certs
If the reader never appears, smartcard redirection may be blocked by policy on the AVD side.
That usually means the .rdpw you’re using targets a desktop/pool you aren’t assigned to (or your access changed).
- Download a fresh
.rdpwfrom the correct desktop tile. - Use
--listto see all.rdpwfiles grouped by tenant and pick the right one.
Some tenants briefly show the correct redirect URL and then redirect to a “wrongplace” page. Workarounds:
- Copy the
...nativeclient?code=...URL immediately when it appears. - If it flips to wrongplace, hit Back once and copy the previous URL.
- The redirect URL you paste into the terminal contains a short-lived auth code. Treat it like a password: don’t paste it into chat logs, tickets, or screenshots.
- Consider keeping terminal scrollback minimal when authenticating.
This is an unofficial helper script. Use it in accordance with your organization’s security policies.