To develop, it is very confortable and secure to use SSH keys with GIT. In this case, an authentification by username and password are not necessary.
The first step to configure your environmment is to have generated SSH keys. If you don't have keys generated, you can follow all the process describe here : SSH Keys.
The second step is the declaration of keys on your repositories platform. For instance, on Github, you must add the key in
Personnal settings / SSH and GPG keys:
The last step is the first connection in ssh to valide the connection. In a console, type the following command:
ssh -T firstname.lastname@example.org
Accept the connection to finish the process :
The authenticity of host 'github.com (xxx.xxx.xxx.xxx)' can't be established. RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxqCARLviKw6E5SY8. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'github.com,xxx.xxx.xxx.xxx' (RSA) to the list of known hosts. Hi yourname! You've successfully authenticated, but GitHub does not provide shell access.
Now you can clone your repository using SSH !
Sometimes you have previously clone repositories using HTTPS. You must reconfigure them if you will use them with SSH.
List the existing remote repositories and their URLs:
git remote -v
The output must be like this:
origin https://server/username/project.git (fetch) origin https://server/username/project.git (push)
Change the remote repository's URL:
git remote set-url origin git@server:username/project.git
If you run the command
git remote -v, the output must be like:
origin git@server:username/project.git (fetch) origin git@server:username/project.git (push)
Now Git will use SSH, instead of HTTPS, to synchronize the repository.