I started borrowing a computer to run XCode and work on my iOS projects. It had been used by another person previously, but had been “wiped,” meaning I am not entirely sure of the process to remove the previous user’s information. I downloaded XCode, copied over my files from my personal computer, and began working on a project.
After writing a commit message, when I pushed my changes to Github, I received this error:
ERROR: Permission to learn-co-students/ios-0616-team-panda.git denied to dimacodes.
fatal: Could not read from remote repository.
Who is dimacodes? Not me. It was the user who had used this computer before I did. Github has a couple of suggested solutions when the wrong user is connected to Git on your computer.
- Set your local Git email address using git config
git config user.email "email@example.com"
- If your commits are still not working, Github suggests checking the
GIT_AUTHOR_EMAILvariables. You can do that like this:
echo $GIT_COMMITTER_EMAIL # prints the value of GIT_COMMITTER_EMAIL echo $GIT_AUTHOR_EMAIL # prints the value of GIT_AUTHOR_EMAIL
If they do not contain the right value, you can change them by setting them equal to your email address.
For some users, this will be enough to override the previous email address associated with Git and allow you to push your changes up to Github using your account. However, after changing these values, I was still getting the same error message. Github did not have many more suggestions.
A couple more things we tried: recloned the project and made my changes to the freshly cloned directory. Committing and pushing the changes in the second repository, resulted in the same error message: Permission to…denied to dimacodes.
The Answer: ssh-agent
ssh-agent is a program to hold private keys used for public key authentication (RSA, DSA, ECDSA). The idea is that ssh-agent is started in the beginning of an X-session or a login session, and all other windows or programs are started as clients to the ssh-agent program. Through use of environment variables the agent can be located and automatically used for authentication when logging in to other machines using ssh(1).
SSH-Agent keys will remain cached via the OS Keychain. This is to save you the trouble of re-authenticating every time. In most cases, this is a great feature and your cached key will remain there forever. In order to force the removal of a cached key, you can kill it by using: ssh -a -D.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|// ♥ ssh-add -D|
|All identities removed.|
|// ♥ ssh firstname.lastname@example.org|
|Permission denied (publickey).|
|// ♥ ssh-keygen|
|Generating public/private rsa key pair.|
|Enter file in which to save the key (/Users/flatironschool/.ssh/id_rsa):|
|Enter passphrase (empty for no passphrase):|
|Enter same passphrase again:|
|Your identification has been saved in /Users/flatironschool/.ssh/id_rsa.|
|Your public key has been saved in /Users/flatironschool/.ssh/id_rsa.pub.|
|The key fingerprint is:|
|// ♥ ls|
|id_rsa id_rsa.pub known_hosts|
|// ♥ cat id_rsa.pub | pbcopy|
|// ♥ ssh email@example.com|
|PTY allocation request failed on channel 0|
|Hi sheafk! You've successfully authenticated, but GitHub does not provide shell access.|
|Connection to github.com closed.|
Leave a Reply