How to Set Up Dev Environment on a Remote Machine
Tags: guides, howto, daytona
Published: 2024-04-24 09:16:58

---
title: How to Set Up Dev Environment on a Remote Machine
published: true
date: 2024-04-16 00:00:00 UTC
tags: Guides, HowTo, Daytona
canonical_url: https://www.daytona.io/dotfiles/how-to-set-up-daytona-with-a-remote-machine
---
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p9def33wobd7jdbhlwfw.png)

In this step-by-step guide, we'll walk you through setting up a dev environment with Daytona on a remote machine. Daytona is a powerful tool for creating and managing development environments on local or remote machines.

In this example, we'll use an Azure ARM machine with 8 vCPUs, 16 GB of RAM, and 300 GB of storage. You can play around with different server specifications or utilize whatever is accessible to you, maybe a homelab machine or that server you have tucked away in a corner. This will affect the number of workspaces you can have concurrently and the overall user experience.

**TLDR:**

- **Prepare Remote Machine:** Install Docker and set permissions.

- **Configure Daytona Target:** Add a remote machine as a target in Daytona.

- **Integrate Git Providers (Optional):** Add GitHub or other providers to Daytona.

- **Create and Access Workspace:** Use Daytona to create and open a workspace in VS Code.

## Prerequisites:

- Daytona daemon running on a local machine

- A remote machine with Docker installed

- SSH access to the remote machine

- A GitHub account with a personal access token

## Step 0: Set Up Daytona on Your Local Machine

Before you can start using Daytona with a remote machine, you need to ensure that Daytona is properly set up on your local machine. If you haven't installed Daytona yet, don't worry! We've got you covered with a simple one-liner that will get you up and running in no time.

### Installing Daytona

To install Daytona on your local machine, open a terminal and run the following command:

```
(curl -sf -L https://download.daytona.io/daytona/install.sh | sudo bash) && daytona server -d
```

This command will download the Daytona installation script from the official Daytona website and execute it using `sudo` privileges. The script will guide you through the installation process, ensuring that all the necessary dependencies are installed and configured correctly.

### Starting the Daytona Server

Once the installation is complete, the command will automatically start the Daytona server in the background using the `-d` flag. This means that you can continue using your terminal for other tasks while Daytona runs in the background.

If you ever need to stop the Daytona server, you can do so by running:

```
daytona server stop
```

And to start it again, simply run:

```
daytona server start
```

### Verifying the Installation

To verify that Daytona is installed and running correctly on your local machine, you can run the following command:

```
daytona version
```

This command will display the currently installed version of Daytona, confirming that the installation was successful.

With Daytona now set up on your local machine, you're ready to move on to the next step and prepare your remote machine for use with Daytona. In the following steps, we'll guide you through the process of installing Docker on the remote machine, configuring the necessary permissions, and adding the remote machine as a target in Daytona.

## Step 1: Prepare the Remote Machine

1. [Install Docker](https://docs.docker.com/engine/install/) on the remote machine if it's not already installed.

2. Add your user to the [Docker](https://www.daytona.io/definitions/d/docker) user group by running the following command:

```
sudo usermod -aG docker $USER
```

1. Set the appropriate permissions for the Docker socket by running:

```
sudo chmod 666 /var/run/docker.sock
```

## Step 2: Set Up the Target

Daytona utilizes the concept of targets, allowing you to add remote machines for deploying and [managing development environments](https://www.daytona.io/definitions/d/development-environment-management-dem). By default, Daytona includes a Docker provider, enabling you to spin up environments on your local or remote machine inside Docker container.

1. Open the Daytona CLI and run `daytona server target list` to view the available targets.

2. Set a new target by running `daytona server target set` and selecting the desired provider (e.g., Azure).

3. Provide the necessary information, such as the IP address, username, and SSH key path.

4. Verify that the target was successfully added by running `daytona server target list` again.

## Step 3: Add Git Providers (Optional)

This step is optional since you can simply paste the public Git URL to create a workspace from it.

1. If you want to use your own [Git](https://www.daytona.io/definitions/g/git) repositories directly with Daytona, you need to add a Git provider. We will use GitHub, but you can use GitLab, Bitbucket, Gitea, or Codeberg. You can also check our guide on [how to select Git provider](https://dev.to/nkko/comprehensive-guide-to-selecting-git-provider-4kmf-temp-slug-1383486).

2. Go to your GitHub settings and navigate to the Developer settings.

3. Create a personal access token with the necessary permissions (repositories access).

4. Add the GitHub provider to Daytona using the generated access token and command `daytona git-providers add`.

 ![](https://www.datocms-assets.com/103916/1713436715-git-providers.png)
## Step 4: Create a Workspace
 ![](https://www.datocms-assets.com/103916/1713438579-choosegitprovider.png)
1. Run `daytona create` to create a new workspace.

2. Choose the desired Git repository, by pasting the repo URL or selecting it from the list of your repositories, and select the target on which you wish to run your workspace.

3. Wait for Daytona to pull the necessary images and set up the workspace.

4. Once the workspace is created, you can view it by running `daytona list`.

 ![](https://www.datocms-assets.com/103916/1713438758-daytonacreate.png)
## Step 5: Open the Workspace in VS Code
 ![](https://www.datocms-assets.com/103916/1713438868-ideselection.png)
1. Set your preferred IDE by running `daytona ide` and selecting VS Code. You can also use web IDE powered by OpenVSCode or any of the JetBrains IDEs.

2. Run `daytona code` to open the workspace in VS Code.

3. VS Code will establish an SSH connection to the remote machine and set up the remote server.

4. Once the connection is established, you can start working on your files within the workspace.

## Step 6: Open the Workspace from a Development Container Specification (Optional)

1. If your workspace includes a dev container specification, you can rebuild the container from it.

2. VS Code will download the necessary images and start the container.

3. Once the container is running, you can access the workspace and make changes on your code.

 ![](https://www.datocms-assets.com/103916/1713438408-reopenincontainer.png)
## Conclusion

Congratulations! You have successfully set up Daytona with a remote machine and created a workspace. You can now work on your projects seamlessly, whether locally or on a remote machine.

If you encounter any issues or have further questions, feel free to contact the Daytona team in our Slack or add an issue to the [Daytona GitHub repository](https://github.com/daytonaio/daytona).