directory

  • Step1: Verify that the SSH keys exist
  • Step2: create an SSH keys
  • Step3: verify that github is linked

The cli terminal is opened

Step1: Verify that the SSH keys exist

ls -al ~/.ssh
Copy the code

See if the file ending in.pub already exists in the return result

Step1.1: open the. Pub file if there is one
cat ~/.ssh/id_rsa.pub
Copy the code

Copy to SSH Keys on Github

Step1.2: if not, jump to Step2

Step2: create an SSH keys

Step2.1: generate ssh-keygen
ssh-keygen -t rsa -b 4096 -C "[email protected]"
Copy the code

[email protected]” is your Github address;

Step2.2: Determine the directory where the key is saved (directly press enter and select the default)

Step2.3: Enter the password (enter the password is not required, and write the password twice)

At this point, two files, public key and private key, are generated in the default path.

Step2.4: add the SSH Key to the ssh-agent
eval $(ssh-agent -s)
Copy the code

Returns the Pid of the agent

ssh-add ~/.ssh/id_rsa
Copy the code

Then enter the password, no password of the direct enter, the prompt added success

Step2.5: open the id_rsa.pub file and copy the file contents to github
# Check the directory
ls -al ~/.ssh
Open the id_rsa.pub file
cat ~/.ssh/id_rsa.pub
Copy the code

Step3: verify that github is linked

ssh -T [email protected]
Copy the code

Github SSH will now be able to link to the MAC and upload and download code