02_Set up SSH - UzanR/UzCodingNewLife GitHub Wiki

Generating a new SSH key

Gen SSH key

$ ssh-keygen -t rsa -b 4096 -C "[email protected]"

Add SSH key to ssh-agent

Open Powershell

Set-Service ssh-agent -StartupType Manual

$ sc config ssh-agent start=auto

$ sc start ssh-agent

Add SSH private key to the ssh-agent

$ ssh-add ~/.ssh/id_rsa

Add the SSH key to your GitHub account

Copy the SSH key to clipboard

$ clip < ~/.ssh/id_rsa.pub

Account -> Settings -> SSH and GPG keys -> Add SSH Key

Change a remote's URL

$ git remote -v

$ git remote set-url origin https://hostname/USERNAME/REPOSITORY.git

Change config file

~/.ssh/config

Host github  
  HostName github.com  
  IdentityFile ~/.ssh/id_rsa  
  User git  

Lỗi

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that a host key has just been changed. The fingerprint for the RSA key sent by the remote host is 51:82:00:1c:7e:6f:ac:ac:de:f1:53:08:1c:7d:55:68. Please contact your system administrator. Add correct host key in /Users/isaacalves/.ssh/known_hosts to get rid of this message. Offending RSA key in /Users/isaacalves/.ssh/known_hosts:12 RSA host key for 104.131.16.158 has changed and you have requested strict checking. Host key verification failed.

Cách 1:Just edit ~/.ssh/known_hosts and delete line 12

Offending RSA key in /Users/isaacalves/.ssh/known_hosts:12

Cách 2: ssh-keygen to delete the invalid key

ssh-keygen -R "you server hostname or ip"
⚠️ **GitHub.com Fallback** ⚠️