Generate SSH Key on git

Step 1 .Generate SSH Key on git

  1. For Windows (using Git Bash), macOS, or Linux:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

2. Press Enter to accept the default location:

(~/.ssh/id_ed25519 or ~/.ssh/id_rsa)

3. Enter a passphrase (optional but recommended)

you can Enter blank password

This will generate 2 files:

  • Private Key: ~/.ssh/id_ed25519
  • Public Key: ~/.ssh/id_ed25519.pub

Step 2. Add SSH Key to GitLab

i. Login to GitLab

ii. Click your avatar (top-right)Edit Profile

iii. Go to SSH Keys

iv. Paste your copied key into the Key field

v. Set a title (like "My Laptop") and optional expiration

vi. Click Add key

Step 3. Test SSH connection

ssh -T git@gitlab.com

You should see:

Welcome to GitLab, @your_username!

0 Comments

Leave a Reply

You must be logged in to post a comment.