DEV Community

Vikas Prabhu
Vikas Prabhu

Posted on

Gitlab connect using SSH from Macbook

To connect GitLab from your MacBook, you can follow these step-by-step commands:

  1. Open the Terminal application on your MacBook. You can find it in the "Utilities" folder within the "Applications" folder or use the Spotlight search to find it quickly.
  2. Configure your Git identity by running the following commands:

    git config --global user.name "Your Name"
    git config --global user.email "your.email@example.com"
    

    Replace "Your Name" with your actual name and "your.email@example.com" with your email address. These commands set your global Git configuration, which will be used for all your repositories.

  3. Generate an SSH key pair by running the following command:

    ssh-keygen -t ed25519 -C "your.email@example.com"
    

    This command generates an Ed25519 type SSH key pair. When prompted for a file to save the key, you can press Enter to accept the default location (~/.ssh/id_ed25519).

  4. Start the SSH agent by running the following command:

    eval "$(ssh-agent -s)"
    
  5. Add your private key to the SSH agent by running the following command:

    ssh-add ~/.ssh/id_ed25519
    

    If you saved your key with a different filename or location, adjust the command accordingly.

  6. Copy your public key to the clipboard by running the following command:

    pbcopy < ~/.ssh/id_ed25519.pub
    

    This command copies the contents of your public key to the clipboard.

  7. Log in to your GitLab account in a web browser.

  8. Navigate to your GitLab account settings and find the "SSH Keys" section.

  9. Click on "Add SSH Key" or a similar button.

  10. Paste the public key from your clipboard into the "Key" field.

  11. Provide a title for the key (e.g., "MacBook SSH Key").

  12. Click on "Add Key" or a similar button to save the SSH key in your GitLab account.

Now you have successfully connected GitLab from your MacBook. You can clone repositories, push changes, and interact with GitLab using the Git commands in the Terminal. Remember to adjust the repository URLs in the Git commands to match the repository you want to work with.

Top comments (0)