Open a terminal on Linux or macOS, or Git Bash on Windows.
if you have already created ssh key and want to use that, skip the 3,4 and 5 step.
Generate a new ED25519 SSH key pair: ssh-keygen -t ed25519 -C "email@example.com" Or, if you want to use RSA: ssh-keygen -t rsa -b 4096 -C "any comment or email-id" if you dont want to add any comment you can remove -C flag and comment.
It will ask for path to store the key, go with the default so that no extra configuration need to be done.
Once path is set, it will ask for password for security of key-usage(Password is not mandatory you can skip by pressing twice enter key)
Now the key is generated to specified location (C:\Users\username\.ssh). go to the folder there will be two key id_rsa and id_rsa.pub, open the rsa.pub and copy whole content(Do not modify anything by mistake).
For gitlab : go to gitlab -> settings -> SSH key -> Paste the key in specified area