ESP32 Platform Documentation

Cloning

Cloning (public repository)

Clone repository using Git CLI
# Browse to the directory where you want to store the project.
# This example uses the root directory (/) and will create an "esp32" folder there.
# The cloned repository folder will serve as the root directory of the application
# (e.g., /esp32).
cd /
git clone https://github.com/mhoek2/esp32.git

Cloning (private repository) - Linux

When the repository is private, a deployment key is required

If you use a fork, replace 'mhoek2' in the following snippets with your username

  1. Create a public key using ssh-keygen
    # Create a ssh pub key
    cd ~/.ssh/
    ssh-keygen -t rsa -b 4096 -C "esp-deploy"
  2. *Optional SSH host:
    # use git@esp instead of git@github.com
    # for now, use git@github.com in the setup scripts (clone.sh & update.sh)
    
    # Add to ssh config
    nano ~/.ssh/config:
    
    Host esp
      HostName github.com
      User repo-user
      IdentityFile ~/.ssh/esp-deploy
    
    # Test authentication
    ssh -T git@esp
  3. Go to GitHub.com and navigate to: Your repository -> Settings -> Deploy keys
  4. Click Add a deploy key and keep it read-only!
  5. Enter a name, then copy the content of the .pub file in the value field.
    # find the content of the .pub key:
    cat ~/.ssh/esp-deploy.pub
  6. Create a clone.sh file
    # dedicated server:
    # cd to the root of the webserver.
    cd /var/www/html
    
    # or for docker:
    cd /
    
    sudo nano clone.sh
  7. Write to clone.sh
    #!/bin/bash
    #
    
    # Check if ssh-agent is running
    if [ -z "$SSH_AUTH_SOCK" ]; then
        echo "Starting ssh-agent..."
        eval "$(ssh-agent -s)"
    fi
    
    # Check if the key is already added
    if ! ssh-add -l | grep -q "esp-deploy"; then
        echo "Adding SSH key..."
        ssh-add ~/.ssh/esp-deploy
    else
        echo "SSH key already added."
    fi
    
    # Clone the repo
    git clone git@github.com:mhoek2/esp32.git
  8. Make clone.sh executable
    sudo chmod +x clone.sh
  9. Run clone.sh
    ./clone.sh

Search results