Saltar al contenido

Lección 7 · Remote Storage

Cloud and SSH Remotes: Setup and Credentials

Configure DVC remotes on Amazon S3, S3-compatible services, Google Cloud Storage, Azure Blob and SSH, and keep secrets out of Git with local configuration.

Teams usually keep data in object storage or on a server. DVC supports many backends: Amazon S3 and compatible services, Google Cloud Storage, Azure Blob Storage, SSH and SFTP, HTTP, WebDAV, HDFS, Google Drive, Aliyun OSS, and local folders. The commands stay the same; only the URL and the authentication change.

Option names below were checked against the DVC documentation as of December 2026. Providers change their authentication advice, so read the page for your backend before production use.

The safe pattern

Split settings in two:

  1. Shared, non-secret settings (bucket path, region, endpoint) go in .dvc/config, committed to Git.
  2. Secrets and personal paths go in .dvc/config.local using --local, or come from your cloud provider's standard credential tools.

The best option is often no secret in DVC at all: sign in with the provider's command-line tool, or give the CI job or server a role that can read the bucket.

Amazon S3 and compatible services

Terminal
# Read-only: an S3 remote
pip install "dvc[s3]"
dvc remote add -d s3store s3://my-team-bucket/review-model
dvc remote modify s3store region eu-central-1
dvc remote modify --local s3store profile data-team

By default DVC follows the usual AWS configuration. Other options include credentialpath, configpath, access_key_id, secret_access_key and session_token. Set any key values with --local only. For S3-compatible services (for example, self-hosted object storage), set endpointurl:

Terminal
# Read-only: an S3-compatible endpoint
dvc remote modify s3store endpointurl https://storage.example.internal

Google Cloud Storage

Terminal
# Read-only: a GCS remote
pip install "dvc[gs]"
dvc remote add -d gcs gs://my-team-bucket/review-model
gcloud auth application-default login
# or, for a service account key file:
dvc remote modify --local gcs credentialpath /secure/key.json

The GOOGLE_APPLICATION_CREDENTIALS environment variable also works. Keep key files outside the repository.

Azure Blob Storage

Terminal
# Read-only: an Azure remote
pip install "dvc[azure]"
dvc remote add -d azure azure://my-container/review-model
dvc remote modify azure account_name mystorageaccount

DVC can try Azure's default credential and needs account_name. Other options include connection_string, a service principal (tenant_id, client_id, client_secret), account_key or sas_token. Store secret values with --local.

SSH and SFTP

Terminal
# Read-only: a server reached over SSH
pip install "dvc[ssh]"
dvc remote add -d lab ssh://lab.example.com/srv/dvc-storage
dvc remote modify --local lab user your-login
dvc remote modify --local lab keyfile ~/.ssh/id_ed25519

The server must allow both SSH and SFTP. The SFTP root folder may differ from the real file system root, so check the path. Other settings include port, ask_passphrase, allow_agent and max_sessions (lower it if you see errors about creating SFTP connections).

Cloud versioning (a note)

S3, Azure and Google Cloud Storage offer object versioning. DVC can use it, for example with dvc import-url --version-aware, which records version information for imported objects. Versioning must be turned on in the storage service, and lifecycle rules that delete old versions can lose data that DVC cannot recover. Read the cloud versioning guide before relying on it.

Review configs before you commit

A short script can catch secrets in a config file before they reach Git. This stand-in is a teaching aid with a few rules, not a real security scanner. Use a proper secret scanner and your provider's tools too.

Python Stand-in: look for secrets in a DVC config

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

If a secret was committed, removing it in a new commit is not enough, because it stays in Git history. Revoke or rotate the credential first, then clean the history if your policy requires it.

Access control and safety

  • Grant the least privilege needed: many users only need to read; only a few need delete rights.
  • Turn on bucket versioning or backups to recover from mistakes.
  • Block public access unless the data is meant to be public.
  • Treat remote objects as sensitive as the original data. Hashed names do not hide the contents.
  • Check where data may legally be stored, especially personal data.

Troubleshooting authentication

Symptom Check
"Unable to find credentials" Provider credential setup, or options set with dvc remote modify
"Unable to connect" Network, and endpointurl for S3-compatible storage
Bucket does not exist Bucket name, region and endpoint
SSH session errors Lower max_sessions, test with plain ssh and sftp

Run a command with -v for a detailed log. Check the log for secrets before you share it.

One project, two environments

Teams often need different access in different places. A developer laptop uses a personal sign-in, a build server uses a service identity, and a production job uses a read-only role. Because secrets are not in .dvc/config, the same committed remote definition works everywhere, and each environment supplies its own credentials.

A short checklist for a new environment:

  1. Install DVC with the correct extra.
  2. Set up the provider credentials, or run dvc remote modify --local for the few options that need it.
  3. Run dvc remote list to confirm the address.
  4. Pull one small file first to test access.
  5. Confirm that the identity cannot do more than it needs, for example that a read-only job cannot delete objects.

If step 4 fails, test the same credentials with the provider's own tool. If that also fails, the problem is access or network, not DVC.

Naming and layout in a bucket

Use a dedicated bucket or prefix for each project, such as s3://my-team-bucket/review-model. It makes access rules, cost reports and cleanup easier. Sharing one prefix between unrelated projects saves a little space through deduplication, but it raises the risk that cleanup in one project removes data another project needs.

When credentials change

Keys expire and people leave teams. Because credentials live outside Git, you can replace them without a commit. Keep a short note in the README that says who grants access and how to request it, and remove access promptly when someone no longer needs it. Review the list of identities with write or delete rights from time to time.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. Where should a secret access key set through DVC be stored?

    The local config is ignored by Git.
  2. 2. Which option points DVC at an S3-compatible service?

    endpointurl sets the service address for compatible storage.
  3. 3. A key was committed by accident. What comes first?

    Assume the key is exposed. Rotating it removes the danger; history cleanup comes after.
  4. 4. What does an SSH remote require on the server?

    DVC acts as an SSH and SFTP client; there is no DVC server.

Summary

  • Install the backend extra, add the remote by URL, then set options with dvc remote modify.
  • Keep bucket paths shared and secrets in .dvc/config.local or provider tools.
  • S3-compatible storage uses endpointurl; SSH needs SFTP too.
  • Grant least privilege, enable backups, and rotate exposed keys.

Next: Import and Reuse Data from Other Projects

Tu progreso se guarda en este navegador. No necesitas una cuenta.