GitLab generate and add SSH keys
15.08.2023 • 2 dakikalık okuma
Are you keep coming back to remember what commands to use when you need to setup your GitLab? Whether you're using Windows, macOS, or Linux, I've got you covered.
Windows
Open Git Bash and follow.
-
Generate SSH Keys: If you don't already have SSH keys, you can generate them using Git Bash.
Create
.ssh
folder if you don't have one:mkdir ~/.ssh
cd ~/.ssh ssh-keygen -t rsa -b 4096 -C "example@berkekaragoz.com"
-
Start SSH Agent: Run the following command in Git Bash to start the SSH agent:
eval "$(ssh-agent -s)"
-
Add SSH Key to Agent: Add your SSH private key to the SSH agent:
ssh-add ~/.ssh/name_of_the_key
-
Copy Public Key: Copy your SSH public key to the clipboard:
clip < ~/.ssh/name_of_the_key.pub
-
Add Public Key to GitLab: Log in to your GitLab account. Go to "Settings" > "SSH Keys." Add the copied key and save it.
-
Test Connection: In Git Bash, run:
ssh -T git@gitlab.com
macOS
-
Generate SSH Keys: If you don't have SSH keys, generate them by running:
ssh-keygen -t rsa -b 4096 -C "example@berkekaragoz.com"
-
Start SSH Agent: Start the SSH agent:
eval "$(ssh-agent -s)"
-
Add SSH Key to Agent: Add your SSH private key to the SSH agent:
ssh-add -K ~/.ssh/name_of_the_key
-
Copy Public Key: Copy your SSH public key to the clipboard:
pbcopy < ~/.ssh/name_of_the_key.pub
-
Add Public Key to GitLab: Log in to your GitLab account. Go to "Settings" > "SSH Keys." Add the copied key and save it.
-
Test Connection: In the terminal, run:
ssh -T git@gitlab.com
Linux
-
Generate SSH Keys: If you don't have SSH keys, generate them using:
ssh-keygen -t rsa -b 4096 -C "example@berkekaragoz.com"
-
Start SSH Agent: Start the SSH agent:
eval "$(ssh-agent -s)"
-
Add SSH Key to Agent: Add your SSH private key to the SSH agent:
ssh-add ~/.ssh/name_of_the_key
-
Copy Public Key: Copy your SSH public key to the clipboard:
cat ~/.ssh/name_of_the_key.pub | xclip -selection clipboard
-
Add Public Key to GitLab: Log in to your GitLab account. Go to "Settings" > "SSH Keys." Add the copied key and save it.
-
Test Connection: In the terminal, run:
ssh -T git@gitlab.com
Now, you can interact with your repositories without the hassle of entering credentials every time.
You can add them to GitHub as well, so you get the cool verified badge on your commits :>
"GitLab generate and add SSH keys", 15.08.2023 01:30:00