Skip to main content
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:
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

Step 3: Copy the public SSH key to GitLab

Run the following command to print your public key:
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

A successful connection returns:

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

Clone the repository and create a test file:
Error → Fix: If Git prompts you to set up a global identity, run the following commands, then retry the commit:

Push changes

Pull changes

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

References

Last modified on October 12, 2026