git - use ssh to connect to remote warehouses


foreword

Before working on the project, I hope you have installed node.js and Git Bash Here

1. Obtain email and password

1. Configure your name and email locally

git config --global user.name "你的名字"
git config --global user.email "你的邮箱"

Of course, if you are a remote warehouse that cannot be connected due to other reasons such as the low version of Git Bash Here, it means that you have a name and password, so you can directly use the second step to obtain your local email and password.

2. Use the command to get your local email and password

git config --global -l

The effect is as shown below
insert image description here

2. Generate ssh public key

1. Open Git Bash Here in any folder path and enter the following command and press Enter three times

ssh-keygen -t rsa -C "你的邮箱"

insert image description here

2. Open the folder according to the address in the red box above

insert image description here

3. Open and view the id_rsa.pub file

insert image description here

3. Connect ssh on GitHub

1. Find the settings (settings)

insert image description here

2. Find SSH and GPG keys on the left (SSH and GPG keys)

insert image description here

3. Click News SSH key

insert image description here

4. Enter the title (Title) and key (key) and click Add SSH key to add a new ssh key

insert image description here

The new ssh key needs to verify the git password

5. After the addition is successful, return to SSH and GPG keys to see your newly added ssh key

insert image description here

4. Verification

1. Open Git Bash Here and enter the following command

ssh -T [email protected]

2. If it is the first time setting, the following command will appear, just enter yes

insert image description here
In this way, even if the connection is successful


Guess you like

Origin blog.csdn.net/weixin_44784401/article/details/131351345