Home >Development Tools >git >Explain how to set up SSH Key on Git
Git is currently one of the most popular version control software in the world founded by Linus Torvalds. During the development process, we can use Git to perform version control, collaborative development, etc. on the code. When using Git, we can use SSH Key for authentication to facilitate a secure connection between our code base and the server. Below, we will explain in detail how to set up SSH Key on Git.
1. Generate SSH Key
ssh-keygen -t rsa -C "your_email@example.com"
Among them, replace "your_email@example.com" with your email address.
After execution, the following prompt will appear:
Generating public/private rsa key pair. Enter file in which to save the key (/Users/your_user_directory/.ssh/id_rsa):
Just press the Enter key and use the default situation. Next, you will be prompted to enter your password, or you can just press Enter to skip it.
.ssh
directory: id_rsa
and id_rsa.pub
. 2. Add SSH Key to GitHub account
Title is a name for the SSH Key, and Key is the public key content of the SSH Key generated in the terminal (that is, id_rsa. in the
.ssh directory. pub
file contents).
3. Add SSH Key to GitLab account
Title is a name for the SSH Key, and Key is the public key content of the SSH Key generated in the terminal (that is, id_rsa. in the
.ssh directory. pub
file contents).
4. Add SSH Key to Bitbucket account
Title is a name for the SSH Key, and Key is the public key content of the SSH Key generated in the terminal (that is, id_rsa. in the
.ssh directory. pub
file contents).
5. Test SSH Key
Enter the following command in the terminal:
ssh -T git@github.com
Taking GitHub as an example, if the following prompt appears, it means success:
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
If you encounter connection problems, you need to further check the SSH Key configuration, firewall, etc.
The above is the detailed content of Explain how to set up SSH Key on Git. For more information, please follow other related articles on the PHP Chinese website!