Search code examples
gitgithub-for-mac

how to revoke github ssh access?


I was on a public computer and set up for a demo so i could do a git clone using ssh. Now i need to return the public computer but how do i revoke ssh so that no one else can do a git pull/push from this computer to my repo ? I saved some kind of key i think earlier but i dont remember. I am using a mac.

I have tried removing the repos locally but that doesn't help. I want it so the next person who does this has to enter in a user name and password but when i do it on my new computer it will just work without credentials.


Solution

  • There is a difference between git and GitHub. To remove ssh access on GitHub all you have to do is login to GitHub as commented above (https://github.com/settings/keys).

    Then delete the ssh key that is linked to this machine. To be sure that you can't ssh to GitHub with that anymore go ahead an try it.

    ssh github.com
    

    You should see a publickey not recognized error.

    At this point the key is no longer good to ssh into GitHub. If you setup your key other places you can check your home directories .ssh folder for any additional setup. If using Mac OS X or Linux:

    cd ~/.ssh/
    

    Once in the ssh folder you could check to see if there is config file. If there is delete and adjust any additional keys as necessary.

    If not you can delete the id_rsa and id_rsa.pub files which were the most likely attached to your GitHub account.

    rm id_rsa
    rm id_rsa.pub
    

    Once deleted any trace of these keys will be lost and if you need to reconnect to GitHub you will have to 1) regenerate keys and 2) login to the GitHub site via a browser to install a new public key.

    I don't see a need to regenerate a new ssh key because your user will probably be trashed if you are on a public computer.