Accessing iCloud Drive on Linux is still a challenge. Apple provides no official client, and there’s no stable or documented API. The iCloud backend in rclone exists, but authentication often fails with an HTTP 400 error. This issue is well known and frequently reported in the documentation and issue tracker.

This article presents a reliable, repeatable method for mounting iCloud Drive as a local filesystem on Ubuntu without full sync or using a web browser.

Install rclone

The easiest way to install rclone on Ubuntu is to use the official script:

curl https://rclone.org/install.sh | sudo bash

After installation, check that rclone is available:

rclone version

Configure rclone

Start the configuration wizard:

rclone config

Create a new remote:

n) New remote

Choose a name for the remote:

name> icloud

Select the iCloud backend:

Storage> icloud

Enter your Apple ID:

Apple ID> your@email.com

Enter your Apple password:

Password> ********

When prompted to authorise rclone:

Authorize rclone with iCloud? (y/n)

If the authentication works, the remote is ready to use. If it fails, the next section offers an alternative method for accessing iCloud Drive.

Why the standard setup fails

The usual setup starts with:

rclone config

It lets you create an icloud remote and tries to walk through Apple’s login flow. But this step often fails (even after completing 2FA) with the following error:

HTTP error 400: Bad Request

This happens because Apple frequently changes how its web authentication works. As of now, this method just isn’t reliable.

The alternative solution

Instead of relying on rclone to handle authentication, we delegate it to a tool that does it well: icloudpd. This utility supports Apple login and 2FA, and it stores the session cookies. These cookies can then be reused by rclone, bypassing the problematic login step.

Install and use icloudpd

Start by creating a Python virtual environment to isolate the install:

python3 -m venv ~/venvs/icloudpd
source ~/venvs/icloudpd/bin/activate
pip install icloudpd

Then launch the authentication:

icloudpd \
  --username your@email.com \
  --cookie-directory ~/icloud-cookies \
  --directory /tmp/icloud-test \
  --only-print-filenames

This command starts an iCloud session, handles 2FA, and saves cookies to ~/icloud-cookies, without downloading any files.

Extract cookies for rclone

The cookies are in LWP format. To use them with rclone, you need to convert them to a standard HTTP cookie string:

grep '^Set-Cookie3:' ~/icloud-cookies/icloud.com \
  | sed -n 's/Set-Cookie3: *\([^=]*=[^;]*\).*/\1/p' \
  | sed 's/^"\(.*\)"$/\1/' \
  | tr -d '"' \
  | grep -E '^(X-|APPLE-)' \
  | paste -sd\; - \
  > cookies_rclone.txt

Sometimes, the X-APPLE-WEBAUTH-VALIDATE cookie contains escape characters (\) that cause issues. This command fixes them:

sed -i 's/\\/"/g' cookies_rclone.txt

Configure rclone with the cookies

Edit your ~/.config/rclone/rclone.conf file to include:

1[icloud]
2type = icloud
3apple_id = your@email.com
4cookies = <contents of cookies_rclone.txt>
5trust_token = <token returned by icloudpd>

Since authentication is already handled, no further interaction will be needed when mounting.

Mount iCloud Drive

First, create a mount point:

sudo mkdir -p /media/$USER/icloud
sudo chown $USER:$USER /media/$USER/icloud

Then mount iCloud Drive:

rclone mount icloud: /media/$USER/icloud \
  --vfs-cache-mode minimal \
  --daemon

iCloud Drive will now appear as a local folder, with on-demand access to your files.

Automate mounting with systemd (user mode)

Create a systemd service in your user directory:

File: ~/.config/systemd/user/rclone-icloud.service

 1[Unit]
 2Description=Mount iCloud via rclone
 3After=network-online.target
 4
 5[Service]
 6ExecStart=/usr/bin/rclone mount icloud: /media/%u/icloud --vfs-cache-mode minimal
 7Restart=on-failure
 8User=%u
 9
10[Install]
11WantedBy=default.target

Enable and start the service:

systemctl --user daemon-reload
systemctl --user enable --now rclone-icloud.service

This will automatically mount iCloud Drive every time you log in.

Limitations and notes

  • Session cookies expire regularly. You’ll need to run icloudpd again from time to time to refresh them.
  • Write performance may be limited. iCloud Drive isn’t designed for use as a local filesystem.
  • This approach relies on unofficial methods. If Apple changes anything, it might break.

Conclusion

iCloud authentication with rclone is unreliable. But by using icloudpd to fetch session cookies and injecting them into a minimal config, you get a working, reproducible iCloud Drive mount on Ubuntu fully scriptable and browser-free.