Mac configure SSH public key

Mac configure SSH public key


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 view all files in the directory

ls

Check whether there is a file named id_rsa.pub in the directory.

Public key file s.png

If it already exists and no new public key is needed, you can directly open the file and obtain the public key.
Enter the following command to open the file:

cat id_rsa.pub

Inside the red box is the SSH public key

Public key.png
If you have this file but need a new one, please continue to step 3;
if you do not have this file, please skip step 3 and continue 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 public key

Enter the following command to generate the public key:

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

Replace your email address with the above position. After entering the command, there will be several prompts to set 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 as prompted. (If you set a password, some git operations in the future will require a password, such as submitting code) After completing the generation of the public key, you can refer to step 2 to view the generated public key.

Guess you like

Origin blog.csdn.net/meimeieee/article/details/131760222