1. Git configuration
The SSH connection is used to connect to the GIT server, so passwordless login requires the use of public and private keys.
1) Generate public/private keys
Enter the ssh-keygen command in the Git Shell, press Enter to use the default path and file name, and then press Enter when prompted for the password.
The reason I tossed it for a long time was because GIT could not find the private key file because the default file name was not used.
2) Publish the public key
Add the generated id_rsa.pub to the server's .ssh/authorized_keys.
You can use ftp/scp to transfer the file to the server, and then execute:
cat id_rsa.pub >> .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
Note: Make sure that the permission of authorized_keys is 600. If the permission is incorrect, some SSH servers will not recognize this file.
If you are using GitHub, log in to github, click Accounting settings in the upper right, select SSH key, click Add SSH key, and copy the content in id_rsa.pub.
2. TortoiseGit configuration
So far, git has been able to achieve password-free login. But when using TortoiseGit, you will still be prompted for a password, because the key used by TortoiseGit is not the same as git, it uses putty. To use the key just generated, a conversion is required.
1) Generate public/private keys
Open "puttygen.exe", click "load", select the last private key file id_rsa, and then "save private key" to save it as a ppk file.
2) Specify the private key to use
In TortoiseGit's Settings, specify Putty Key as the ppk file generated in the previous step.
In this way, TortoiseGit can achieve password-free login.
1. How to generate ssh public key
You can generate sshkey as follows:
ssh-keygen -t rsa -C "[email protected]"
# Generating public/private rsa key pair...
# 三次回车即可生成 ssh key
Check your public key and add it to the code cloud (Gitee.com) SSH key add address: https://gitee.com/profile/sshkeys)
cat ~/.ssh/id_rsa.pub
# ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6eNtGpNGwstc....
After adding, enter in Terminal (Terminal)
ssh -T git@gitee.com
If return
Welcome to Gitee.com, yourname!
It proves that the addition is successful.
Note: The path of the git code must be SSH to achieve password-free login. Many people use the http method by default, which will cause the password to be entered every time.