What happened? You can’t push code to Github! Can you still play happily?

Error as follows:

After August 13, the user name and password cannot be usedPush, forcing you to changeSSHThe way. Let’s start with solutions:

Check whether there is a key

Mac:

/Users/Your_Name/.ssh
Copy the code

Replace Your_Name with your username Windows:

C \ user \ own username \.sshCopy the code

If so, there are the following files:So congratulations, go straight to step three! If not, continue [Step 2].

Generate a new SSH

2.1 Generation by Running commands

ssh-keygen -t rsa -C "[email protected]"
Copy the code

You will then be prompted to generate a path and so on. Remember the path and press Enter:

2.2 file

Get id_rSA. pub for [step 3]!

3. Bind SSH

Github: [Settings] -> [SSH and GPG keys] -> [New SSH key]

Settings

SSH and GPG keys

Add new SSH keys

Modifying project Remote

After adding SSH keys, we need to change the project from HTTP to SSH:

git remote -v
git remote set-url orgin ssh-url
git push
Copy the code

Replace the ssh-URL with the actual address, taking the SSH address from here:

And then it worked! The diagram below:At this point, you can continue to have fun!

Four, SSH,

4.1 the advantages

  • Dedicated to GitHub and can be generated on a per-use or device basis
  • The token can be revoked at any time without affecting other tokens
  • Permissions can be set to allow only the access required by the use case
  • Will not be brute force cracking, account password mode will be brute force dictionary cracking

4.2 the principle

SSH is based on asymmetric encryption algorithms

(1) Party B generates two keys (public key and private key). Public keys are public and available to anyone, while private keys are private. (2) Party A obtains party B’s public key and encrypts the information with it. (3) Party B shall decrypt the encrypted information with the private key.

The appendix

Github official stated that SSH generated ruan teacher’s encrypted article