Live Chat

We'll need to share your messages (and your email address if you're logged in) with our live chat provider, Drift. Here's their privacy policy.

If you don't want to do this, you can email us instead at contact@anvil.works.

Setting up an SSH key to clone your Anvil app with Git

Introduction

If you want to git clone an Anvil app from the editor onto your machine, you’ll need to prove who you are. The most robust way to authenticate Git access is to set up an SSH key.

This guide will show you how to set up an SSH key on an Linux server, add the SSH key to your Anvil account and clone your Anvil app onto your server with Git. (This guide was written for Ubuntu 20.04, but the instructions should be the same for any modern Linux distribution.)

Step 1 - Generating the key pair

First, let’s create a key pair on your Ubuntu server. Start by running the command:

$ ssh-keygen

You should see the following output:

Generating public/private rsa key pair.
Enter file in which to save the key (/your_home/.ssh/id_rsa):

Press enter to save the key pair into the .ssh/ subdirectory in your home directory.

You will then be prompted for a passphrase. It’s recommended that you enter one, however it isn’t compulsory.

Enter passphrase (empty for no passphrase):

Next you will see an output similar to:

Your identification has been saved in /your_home/.ssh/id_rsa
Your public key has been saved in /your_home/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:+tHymFI4fMGcyKZ8DPUbGZekbnZZM2tVXYelf5Vwzt4 user@host
The key's randomart image is:
+---[RSA 3072]----+
|         ... . +B|
|      . ..o   *o+|
|     o =.=  + o+.|
|    . +.O  o =..o|
|   . * .S+o o  .E|
|    o *++o .    .|
|     ..+o .      |
|      .. *       |
|       .+ .      |
+----[SHA256]-----+

Now you have a public and private key that we can use for authentication between your server and Anvil (or any other Git server).

Step 2 - Copying your Public key

Next, let’s get your Public key: $ cat ~/.ssh/id_rsa.pub

That will show you the public key, which you can then copy to your clipboard:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDhgXxI+HhUJwrYgO2ASMj0hGAtzDYDj0DGNCYF8At7
+3seJjHPl45wMdFe1oUexMRcegcKpYL0gpdtfE34zN8CapbQcmNaRmdCaXxL50cbZRIlWn2OaDxUgbbpH
KzqJdzEuLbTIrYIcvf6OLheTjR7lj/j+342matgOxnKjqJJkFDb226zwxgCAUxhLw+HMuc1LbSM+S0G/N5
UWd1KtO6D0MiiUDZjPKjhdtJ3bpyiV9sJkEGIa5tSWLv/6zBEj4zjWKsyti/OA8UekuRdknVmNDYMNNCkD
bWtRwR4xUdi2wePPkTdA6EMdWmHq9UwAT5F2oCX9KDHvZ5a6JHZzSnQ9O4kUHyT/9uqgZJx4Y
CRZCFBIdCF9eK9HFmFJ9IOywZqjvKjLtm7RRKYP3DkWlVzPo10FGB6EUbeHjV5LZpmJmPBAhcdJRsJAbT
Z4YYm8SeFcmTTo8Ji07UslhmOapGh6frDUZGRWiznuxpHp2AUcCt6uH2uUxuQxwoQhkzUHE= user@host

We will then add this public key to your Anvil account.

Step 3 - Adding the public key to your Anvil account

Login to your Anvil account and open the app you would like to clone to your Ubuntu server.

Click the Clone with Git button in the Version History dialog and paste the public key into the SSH public key box.

Git Access

Git access

Step 4 - Cloning your Anvil app onto your server

Now we have our keys set up, we can clone our Anvil app onto our server using the command found at the top of the Git access screen.

It will look similar to:

$ git clone ssh://ryan%40anvil.works@anvil.works:2222/NEFKG4LJ2OZEZEXK.git AppName

If you entered a passphrase when creating your SSH key in step 1, you will be prompted for the passphrase.

Your app will now be cloned to your Linux machine and is ready to use with the Anvil App Server.