Git Ready Part 2
Now that we have the empty remote repo copied to the local repo, we neet to take care of one more very important thing before we can start pushing code to remote.
When you attempt to push code to GitHub without completing the steps that I am going to lay out for you, you will more than likely receive this error message:
remote: Support for password authentication was removed on August
13, 2021. Please use a personal access token instead.
fatal: Authentication failed for 'https://github.com/username/repo.git/'
To prevent this we are going to push code via SSH
What is SSH?: SSH (Secure Shell) is a cryptographic network protocol for securely accessing and managing remote systems over an encrypted connection.
Setting up SSH (Linux + Mac)
- Generate SSH Key:
- Run
ssh-keygen -t ed25519 -C "your_email@example.com"
in the terminal. -
Press Enter to accept the default location.
-
Start SSH Agent:
-
Run
eval "$(ssh-agent -s)"
to start the SSH agent. -
Add SSH Key:
-
Run
ssh-add ~/.ssh/id_ed25519
to add the key. -
Copy SSH Key:
-
Run
cat ~/.ssh/id_ed25519.pub
and copy the output. -
Add SSH Key to GitHub:
- Go to GitHub > Settings > SSH and GPG keys > New SSH key.
-
Paste the key and save.
-
Test Connection:
-
Run
ssh -T git@github.com
to verify the connection. -
Set SSH Remote URL:
- Run
git remote set-url origin git@github.com:username/repo.git
.
You're now ready to push code to GitHub using SSH!