I’m using Cygwin in the office for most of the Linux based tasks and one of them is using git. I’ve been trying to use my github account but failed several times. Finally, I have come up with the solution lately after tons of research and trial and error.
When it is your first time in using github services (assuming you know the basics of git), you will eventually fail to push changes to your github repositories. First, you must have a github account. Assuming that you have not done anything unusual with your account, you will experience just what I’ve experience when trying to push changes.
Before pushing and wasting your time knowing that it will fail, just try this simple testing if your machine can connect to github.
$ ssh git [at] github [dot] com Permission denied (publickey)
If you get the same result as above, the permission denied (publickey) error message, then I say welcome to the club! That is just part of being a newbie anyway. The message simply says that your public key was rejected by github because it is not integrated to your account.
The Simple Solution
The simple solution is to manually create you own public key and we will associate it to your github account later. Please note that the email address that you use for github must be the same as the email address you’ve used to create your public key.
Here is how to create your own public key.
$ ssh-keygen -C "your [at] email [dot] com" -t rsa
Make sure to enter a passphrase (your password). Your rsa public key will be saved under ~/.ssh/id_rsa.pub.
The next step is to open your github account via web and go to Account Settings. Find your email address from the list, usually there is one entry with your email address as the title. Click EDIT and paste (copy and paste) the key from ~/.ssh/id_rsa.pub then save your changes.
Now let’s try it again.
$ ssh git [at] github [dot] com Enter passphrase for key '/home/YourUserName/.ssh/id_rsa': PTY allocation request failed on channel 0 ERROR: Hi YourName! You've successfully authenticated, but GitHub does not provide shell access Connection to github.com closed.
If that is what you get, it means we have just successfully configured our machine to connect to github. Try pushing changes to your repo and enjoy the service.