# Attach an Orchard project > Load a project environment's variables and database URL into a Greenhouse machine as an env file. Only the host can attach a project, and the host needs edit access to it. Source: https://docs.orchard.hackclub.com/greenhouse/projects/ An agent that runs your app needs the same configuration as your deployed app. Instead of copying variables by hand, attach a project to the machine. Orchard writes one of the project's [environments](/run/environments/) into the machine as an env file that shells load, and keeps the file up to date when the variables change. ## Prerequisites - Host access to the machine. - [Edit access to the project](/teams/organizations/#project-roles). - A project that belongs to the machine's organization. ## Attach a project **Dashboard** 1. Open the machine menu. 2. Select **Machine settings**. 3. Under **Projects**, select **Attach**. 4. Select a **Project** and an **Environment**. 5. Select **Attach** to confirm. **CLI** ```bash orchard sandbox link add my-machine storefront --env staging ``` If you omit `--env`, Greenhouse uses the project's default environment. To list attached projects, run `orchard sandbox link list my-machine`. A machine can have one environment per project. Attaching another environment of the same project replaces the first. The [audit log](/teams/audit-logs/) records each attach and detach. ## Use the variables Each attached project becomes a file: ```text ~/.config/orchard/env/.env ``` Login shells, terminals, and scripts load every file in that directory: ```bash echo $STRIPE_PUBLISHABLE_KEY psql "$DATABASE_URL" ``` The file is readable only by the `dev` user. Orchard rewrites it on each sync, so do not edit it. When you change a variable on the environment, Orchard updates the file. Open shells keep the values they loaded. Open a new terminal to pick up changes. ## File contents The file contains: - **Shared variables:** The environment's shared variables, as `KEY='value'` lines. - **`DATABASE_URL`:** The connection string of the environment's first managed database, if [public access](/data/databases/#public-access) is on for that database. The connection uses TLS and the public address. If public access is off, the file has a comment instead. The file leaves out these values and adds a comment for each: - **Secret variables:** Orchard keeps secret values write-only. Set them on the machine yourself. - **Variables that change how tools run:** For example, `PATH`, `HOME`, `LD_PRELOAD`, `GIT_*`, `NODE_OPTIONS`, and `ANTHROPIC_BASE_URL`. If the environment defines its own `DATABASE_URL`, the file uses that value. ## Who can read the values The host and guests can read the file, because they can open terminals on the machine. Attach only variables that you are comfortable sharing with those people. If the person who attached a project loses edit access to it, Orchard stops writing its variables to the machine. ## Detach a project **Dashboard** 1. Open the machine menu. 2. Select **Machine settings**. 3. Under **Projects**, select the **X** next to the project. **CLI** ```bash orchard sandbox link remove my-machine storefront ``` Orchard removes the env file on the next sync. ## Related resources - [Configure setup and run scripts](/greenhouse/scripts/) - Use the attached variables in setup and run scripts. - [Share a machine](/greenhouse/sharing/#what-sharing-gives-your-guests) - Review what guests can read on a machine, including env files.