You are viewing documentation for a legacy Rasa product. If you want to get started building assistants with Rasa please check out our latest [documentation here](/content/docs/index.html).

If you want to use self-generated SSH keys or prefer to use the Rasa Enterprise API for any other reason, you can also use the [Rasa Enterprise HTTP API](https://legacy-docs-enterprise.rasa.com/docs/rasa-enterprise/pages/http-api) to connect Rasa Enterprise to your Git repository.

##### caution

When connecting the Rasa Enterprise instance to a git repository, **any training data or configuration files**  **stored in Rasa Enterprise will be overwritten by those in the Git repository**. If you were using Rasa Enterprise to manage your assistant before setting up Integrated Version Control, be sure to download the data before continuing, so that the data is not lost. You can push the downloaded data from your machine to your Git repo before or after connecting it to Rasa Enterprise.

## Using SSH to Authenticate [#](https://legacy-docs-enterprise.rasa.com/docs/rasa-enterprise/installation-and-setup/post-deploy-steps/integrated-version-control-via-api/#using-ssh-to-authenticate "Direct link to heading")

1. To authenticate your Rasa Enterprise server with the remote repository via SSH, you need to set up an SSH key that Rasa Enterprise can use for authentication. Please **create a new, single-use SSH key** for this (see instructions below). Also, make sure to restrict the SSH keys to only apply to your assistant’s repository.

To generate a new SSH key pair follow these steps:

1. Open the Terminal
2. Execute the following command (make sure to not overwrite your own SSH keys):
   
   ```
   ssh-keygen -t rsa -b 4096 -f git-deploy-key
   ```

This provides you a private (`git-deploy-key`) and a public (`git-deploy-key.pub`) key in your current directory.

##### note

Please note that Rasa Enterprise currently does not support password protected private keys.

2. Save your repository information and private key to a file `repository.json`, in the format shown below. If your Rasa Enterprise server does not use HTTPS, we highly recommend doing this directly on your server to avoid compromising the key. As the contents of this file will uploaded via a curl request, the directory where it is stored does not matter, but it is recommended to store the file somewhere secure.

```json
{
  "repository_url":"<your repository's SSH clone url>",
  "target_branch":"<the default branch Rasa Enterprise will use>",
  "ssh_key":"<your generated private SSH key>",
  "is_target_branch_protected":false
}
```

##### note

The **target branch** is the branch that Rasa Enterprise will

- use to show the initial data
   - branch off from when you make new changes
   - return to after you discard or push changes

If you want to disable adding changes directly to the target branch, please specify `is_target_branch_protected": true/false` in the `repository.json` file.

For example, your `repository.json` might look like:

```json
{
  "repository_url":"git@github.com:RasaHQ/rasa-demo.git",
  "target_branch":"main",
  "ssh_key":"-----BEGIN OPENSSH PRIVATE KEY-----\nb3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAACFwAAAAdzc2gtcn\nNhAAAAAwEAAQAAAgEAu/Giin7t8DFMxsaTbyy1To2EQpLIAhpAIgpyC/e45NYVTwKRGCB1\nmxHzt5IWoh7GSWry3pKFBM74UpXxrRPBdCmFeUIiJoslAukNkRSckAUj0VEfOIZLf2SSPg\n......................................................................\nCDHniFksE1SjkAAAEBANJacZeM2Qdk/vditmBQV97Ac2VJL/Btt8Rks2Vb3CORyXQn3Bpb\n+5ZONhmPEoCg4FcZbAm02gYw3dSoBBWz2i8mmAv71mVsNoddWKpDngRFv4PUaITnYYxrZ4\n-----END OPENSSH PRIVATE KEY-----"
}
```

3. To authenticate with the Rasa Enterprise server you can use one of two methods:
   - **API token authentication**: Get your API token by going to the Models screen in Rasa Enterprise and clicking the `Upload Model` button in the upper right-hand corner. Copy  the `api_token` token from the upload command. Similar to in this command, you will add it to the curl command shown below with the `api_token` query parameter.
   - **JWT token authentication**: Use your JWT access token. You can get it from the  [authentication](https://legacy-docs-enterprise.rasa.com/docs/rasa-enterprise/pages/http-api#tag/Authentication) endpoint and pass it within the `Authorization` header.

Once you have prepared your chosen form of authentication, create the repository by executing the following HTTP request from the directory that contains your `repository.json`:

```bash
# with API token authentication
curl --request POST \
 --url http://<Rasa Enterprise server host>/api/git-repositories?api_token=<your api token> \
 --header 'Content-Type: application/json' \
 --data-binary @repository.json

# with JWT token authentication
curl --request POST \
 --url http://<Rasa Enterprise server host>/api/git-repositories \
 --header 'Authorization: Bearer <your access token>' \
 --header 'Content-Type: application/json' \
 --data-binary @repository.json
```

##### note

If your Rasa Enterprise server runs on HTTPS, make sure to use `https://` in the `--url` parameter.

## Using HTTPS to Authenticate [#](https://legacy-docs-enterprise.rasa.com/docs/rasa-enterprise/installation-and-setup/post-deploy-steps/integrated-version-control-via-api/#using-https-to-authenticate "Direct link to heading")

##### note

Connecting to remote repositories via HTTPS is only possible with **Rasa Enterprise**.

1. To authenticate your Rasa Enterprise server with the remote repository via HTTPS, you need the necessary credentials to access the repository: username and password. If your account has 2FA (Two-Factor Authentication) enabled, you will need to create a personal access token that allows you to access the repository, and use that as a password.

2. Use the Rasa Enterprise API to create the repository, using either **API token authentication** or **JWT token authentication**:

```bash
# with API token authentication
curl --request POST \
 --url http://<Rasa Enterprise server host>/api/git-repositories?api_token=<your api token> \
 --header 'Content-Type: application/json' \
 --data-raw '{
   "repository_url": "<your repository HTTPS clone URL>",
   "target_branch": "<the default branch Rasa Enterprise will use>",
   "is_target_branch_protected": false,
   "username": "<your username>",
   "password": "<your password or personal access token>"
}'

# with JWT token authentication
curl --request POST \
 --url http://<Rasa Enterprise server host>/api/git-repositories \
 --header 'Authorization: Bearer <your access token>' \
 --header 'Content-Type: application/json' \
 --data-raw '{
   "repository_url": "<your repository HTTPS clone URL>",
   "target_branch": "<the default branch Rasa Enterprise will use>",
   "is_target_branch_protected": false,
   "username": "<your username>",
   "password": "<your password or personal access token>"
}'
```
