First you need to set your username and email, in the terminal replace and with your own:
git config --global user.name "<USERNAME>" git config --global user.email <EMAIL>
In your terminal type:
ssh-keygen -t rsa
Then it would ask some questions, you can skip all with or fill as you need.
Now you need to copy this SSH key to paste it on github or gitlab as you need:
cat ~/.ssh/id_rsa.pub | pbcopy
With this command you have your SSH key in the clipboard ready to paste it with +
First Logged in, then go to the right up corner and open the user avatar menu, then click on "settings", then go to the left sidebar to the section "SSH Keys", you are going to be able to see a form to add a SSH Key
Go to the right up corner, open the avatar menu, then go to settings, you are going to be able to see in the left sidebar a "SSH & GPG Keys" section, click there and you are going to be able to see all your SSH keys, and a green button to "add new SSH key", Here you can add your new SSH key.