mac configuration git ssh public key

The mac at home has been configured with the public key of gitee, and it is no problem to pull and upload the code.
Today, if you want to configure another mac to gitee, you must first configure the public key, otherwise you will not have permission.
General report:

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Start configuration:

1. Generate public key on mac

1. Enter the .ssh directory,
open the Mac terminal (Terminal), and enter the following command:

cd ~/.ssh

2. Check if there is an existing public key
Enter the following command to check all files in the directory

ls

Check the directory for a file named id_rsa.pub.

public key file s.png

If it already exists and does not need a new public key, you can directly open the file and get the public key.
Enter the following command to open the file:

cat id_rsa.pub

The red box is the SSH public key

Public key.png
If you have this file but need a new one, please proceed to step 3;
if you do not have this file, please skip step 3 and proceed to step 4.

3. Delete the old public key
Enter the following commands in sequence to delete the old public key:

mkdir key_backup
cp id_rsa* key_backup
rm id_rsa*
4. Generate a public key
Enter the following command to generate a public key:

ssh-keygen -t rsa -C “你的邮箱”

Replace your email address with the above position. After entering the command, there will be several prompts for setting a password. If you do not need to set a password, just press the Enter key until the end. If you need to set a password, please enter the password according to the prompt. (If you set a password, some git operations will require a password in the future, such as: submit code) After completing the generation of the public key, you can refer to step 2 to view the generated public key.

2. Configure on gitee

insert image description here
Configuration done! !

Next article: Submit code to gitee on Mac

Guess you like

Origin blog.csdn.net/weixin_44834981/article/details/127489440