Configure github's ssh under mac computer

created at 08-07-2021 views: 2

Step1: Verify whether there are ssh keys

ls -al ~/.ssh

See if there is already a file ending with .pub in the returned result

1.1: If there is a file ending with .pub, open it directly

cat ~/.ssh/id_rsa.pub

Copy to SSH keys on github

1.2: If not, skip to Step2

Step2: Create new ssh keys

Generate ssh-keygen

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

Among them, your_email@example.com is the mailbox associated with your github;

Determine the directory where the key is saved (press Enter directly, select the default)

 select the default

Enter the password

  • you can press Enter directly if no password is required
  • and you set a password if you want

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

Add SSH Key to ssh-agent

eval $(ssh-agent -s)

Return the Pid of the agent

Agent pid 1766
ssh-add ~/.ssh/id_rsa

Then enter the password, if there is no password, press Enter, prompting that the addition is successful

Open the id_rsa.pub file and copy the content of the file to github

# check directory
ls -al ~/.ssh
# open the id_rsa.pub file
cat ~/.ssh/id_rsa.pub

Step3: Verify whether github is linked

ssh -T git@github.com

In this way, github's ssh can be linked to mac, and the code can be uploaded and downloaded~~

created at:08-07-2021
edited at: 08-07-2021: