# Setting Up SSH Key in GitLab > Powered by ChatGPT SSH keys provide a secure way to authenticate yourself to GitLab without needing to enter your username and password every time. This guide will walk you through the steps to set up an SSH key for use with GitLab. ## Prerequisites Before you begin, ensure you have the following: 1. A GitLab account: You must have an account on GitLab where you want to add your SSH key. 2. Git installed: Make sure you have Git installed on your local machine. You can download it from [git-scm.com](https://git-scm.com/downloads). 3. SSH key pair: If you don't already have an SSH key pair, generate one using the `ssh-keygen` command. You should have both the private and public keys. If you need to generate one, use the following command: ```bash ssh-keygen -t rsa -b 4096 -C "your_email@example.com" ``` Replace `your_email@example.com` with your actual email address. ## Adding SSH Key to GitLab Follow these steps to add your SSH key to GitLab: 1. **Copy your SSH public key:** Open a terminal and run the following command to copy your public key to your clipboard: ```bash cat ~/.ssh/id_rsa.pub ``` If your key has a different filename or location, replace `~/.ssh/id_rsa.pub` with the correct path. 2. **Log in to GitLab:** Open your web browser and go to your GitLab instance (`http://gitlab.is1ab.com`). 3. **Navigate to your profile settings:** - Click on your user avatar in the top right corner. - Select "Settings" from the dropdown menu. 4. **Add your SSH key:** - In the left sidebar, click on "SSH Keys." - Click the "Add SSH Key" button. 5. **Fill in the SSH key details:** - Title: Give your SSH key a name to help you identify it later (e.g., "My Laptop"). - Key: Paste your SSH public key into the "Key" field (the one you copied earlier). - Optionally, you can set an expiration date for the key or enable it for specific repositories only. 6. **Add the SSH key:** - Click the "Add key" button. 7. **Confirm your password:** You may be asked to enter your GitLab password for verification. 8. **SSH Key added:** You will see a confirmation message indicating that your SSH key has been added successfully. ## Testing the SSH Key To ensure that your SSH key is set up correctly, you can test it by trying to connect to GitLab via SSH. Open a terminal and run the following command: ```bash ssh -T git@gitlab.is1ab.com ``` If successful, you will see a message like "Welcome to GitLab, @your_username!" This confirms that your SSH key is working correctly with GitLab. Now, you can use Git with SSH to interact with GitLab without needing to enter your password each time. ## Conclusion You have successfully set up an SSH key in GitLab. This key allows you to securely authenticate with GitLab and interact with repositories without the need for a password. Make sure to keep your private SSH key secure and do not share it with anyone.