Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have connected many times to github and know about generating ssh keys and putting the id_rsa.pub into github settings. But for some reason with this install I can not get it to connect. I am just trying to clone a private repo to a new server but when I the clone I get :

Permission denied (publickey). fatal: The remote end hung up unexpectedly

If I run :

ssh -T git@github.com

It tells me I have successfully authenticated.

What else can I try? I am running this on a bitnami stack so maybe that is causing issues? This is probably the problem, I just am not sure what to do about it. There are already a set of keys in the .ssh/authorized_keys dir. I left those alone as this is how I am connecting with putty/pagent. I put the new keys in /.ssh and left the authorized_keys alone. What would be the correct way to set this up? Should I just delete both pairs and start over? Use the same keys for putty and github? Why do I still authenticate if there is a problem?

share|improve this question
    
are you trying to connect from Windows or Linux? I'm confused by your below comment & your mention of putty here –  Sathya Jan 20 '12 at 3:15
    
Hi sorry it is confusing. I am connecting from Windows to the bitnami server with Putty. The bitnami server itself is running Linux. I am trying to connect to github from the Linux server. –  zac Jan 20 '12 at 3:29
    
I've updated my answer. –  Sathya Jan 20 '12 at 4:46

2 Answers 2

up vote 2 down vote accepted

Have you tried creating a new SSH certificate, i.e. key pair?

1 Generate default key pair:

$ ssh-keygen -t rsa -C "defaultuser@gmail.com"

Don't use this if you already have an SSH certificate.

2 Generate additional key pairs:

$ ssh-keygen -t rsa -C "seconduser@gmail.com"

3 Add non-default keys

$ ssh-add ~/.ssh/id_rsa_seconduser
Enter passphrase for /Users/defaultuser/.ssh/id_rsa_seconduser: 
Identity added: /Users/defaultuser/.ssh/id_rsa_defaultuser  (/Users/defaultuser/.ssh/id_rsa_defaultuser)

4 Set SSH configuration file (~/.ssh/config) so SSH knows which key to be used for which server:

Host github.com
  HostName github.com
  User git
  IdentityFile /Users/XXXUser/.ssh/id_rsa

Host github-client
  HostName github.com
  User git
  IdentityFile /Users/XXXUser/.ssh/id_rsa_XXXSECONDUSER

5 Make sure in the .git/config file for the Git project associated with the second user account at Github that you are using correct host name github-client but not github.com:

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = git@github-client:foobarsomeuser/foobar.git
share|improve this answer
    
Thanks! That helped me figure out what to do. The problem was that I was trying to use the default bitnami user. I generated the keys as a new user and now it works! –  zac Jan 21 '12 at 21:23

Seems like your public key is either missing or you've placed an incorrect public key in your keyring. Check if the keyring exists in ~/.ssh. Hard to say without mentioning your OS


There are already a set of keys in the .ssh/authorized_keys dir.

I believe these are the keys required to ssh into the Linux server.

Best way would be to regenerate a new set of private/public keys for github, add the PK to your Linux server keyring and paste the public key over at Github accounts.

share|improve this answer
    
I updated my question to try and explain better. Yes the keys are in ~/.ssh (and another set in authorized_keys). This stack is Linux 64bit I believe. –  zac Jan 20 '12 at 2:55
    
Thanks, I dont understand though. I keep the keys that are there to ssh into the server and create a new set for github? What does it mean to add to the keyring? Do I put it in the .pem I downloaded when setting up the AMI? Please a bit more details. –  zac Jan 20 '12 at 20:44
    
@zac Computist has explained what I meant –  Sathya Jan 21 '12 at 14:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.