Make sure there is at least one file in it (even just the README.md)
ssh-keygen -t rsa -C "your_email@example.com"
or even better:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
It also possible to use ed25519. There are pros and cons, but personally I've had some issues and that is the reason I've chosen to stick to 4096 rsa for now.
macOS:
pbcopy < ~/.ssh/id_rsa.pub
GNU/Linux (requires the xclip package):
xclip -sel clip < ~/.ssh/id_rsa.pub
Windows Command Line:
type %userprofile%\.ssh\id_rsa.pub | clip
Git Bash on Windows / Windows PowerShell:
cat ~/.ssh/id_rsa.pub | clip
or ofcourse copy it via your favorite editor, cat, or whatever suits your needs :)
Copy the contents of the to your SSH keys to your GitHub account settings (https://github.com/settings/keys).
ssh -T git@github.com
Change directory into the local clone of your repository (if you're not already there) and run:
git remote set-url origin git@github.com:username/your-repository.git
Now try editing a file (try the README) and then do:
git add -A
git commit -am "Update README.md"
git push
Add the key to the ssh-agent
ssh-add ~/.ssh/id_rsa
You should not be asked for a username or password. If it works, your SSH key is correctly configured.
Hello Everyone,
Thank you very much for this thread. I am a beginner using github. I have successfully used in the past following instructions (and even set up the key in the past). However, I had to re-install everything from scratch recently. I have the keys established, but for some reason, I cannot link them up with my local instance of git and the online instance.
I am following all of the instructions here, but I keep getting asked for a user name and password.
When I do ssh -T git@github.com, I get:
Offending key for IP in ... (gives directory)
Matching host key in ... (gives directory)
Are you sure you want to continue connecting (yes/no)? yes
When I select yes, it does recognize me. As far as I can tell, it appears my old key is trying to be used versus the new key.
It is mildly annoying as I managed this once before, but cannot accomplish the task again, even with the various support threads.
Thank you for your time and help!
Geoffrey