> ## Documentation Index
> Fetch the complete documentation index at: https://docs.domino.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# How to connect and authenticate to Gitlab & GitHub with ssh keys using the native bash terminal

> Set up SSH keys for GitLab and GitHub on a Linux bash terminal, test the connection, clone a repo, and push/pull changes

Use these steps to set up a Secure Shell (SSH) key using the native Linux bash terminal, test the connection, clone a repository, and perform basic Git operations like pushing and pulling changes.

## Step 1: Install package and generate SSH key

Run the following commands to install Git and generate an SSH key:

```
sudo apt install git
ssh-keygen -t ed25519 -C "your_email@test.com"
```

Follow the prompts to save the key (typically to `~/.ssh/id_ed25519`) and optionally add a passphrase.

## Step 2: Start the SSH agent and add key to the agent

```
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
```

## Step 3: Copy the public SSH key to GitLab

Run the following command to print your public key:

```
cat ~/.ssh/id_ed25519.pub
```

Copy the full output, then add it to GitLab:

1. Go to your GitLab profile settings.
2. Navigate to **SSH Keys**.
3. Paste your SSH key into the **Key** field.
4. Add a descriptive title in the **Title** field.
5. Click **Add key**.

## Step 4: Test the connection

```
ssh -T git@gitlab.com
```

A successful connection returns:

```
Welcome to GitLab, @your_username!
```

## Step 5: Clone a repository, commit, push, and pull

Clone the repository and create a test file:

```
git clone git@gitlab.com:username/repo.git
cd repo
echo "Hello, GitLab!" > testfile.txt
git add testfile.txt
git commit -m "Add a test file"
```

**Error → Fix:** If Git prompts you to set up a global identity, run the following commands, then retry the commit:

```
git config --global user.name "Your Name"
git config --global user.email "you@test.com"
```

### Push changes

```
git push origin main
```

### Pull changes

```
git pull origin main
```

> **Note:** Replace `main` with the appropriate branch name if it differs.

## References

* [Adding a new SSH key to your GitHub account](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account)
* [Add an SSH key to your GitLab account](https://docs.gitlab.com/ee/user/ssh.html#add-an-ssh-key-to-your-gitlab-account)


## Related topics

- [How-to guides](/knowledge-base/how-to-guides-overview.md)
- [Create Projects](/cloud/platform-capabilities/core-concepts/projects/create-projects.md)
- [Adding a new Git Repository to your project using Personal Access Token (PAT)](/knowledge-base/adding-a-new-git-repository-to-your-project-using-personal-access-token-pat.md)
- [Use Workspaces](/cloud/platform-capabilities/core-concepts/workspaces/index.md)
