Permission denied (publickey,gssapi-with-mic) when cloning Git repo

9,357

You shouldn't just copy the key around. Create a new key for the machine you are using in the same way as you created the one you are copying. According to this page, you should do:

  1. Create the key

    ssh-keygen -t dsa
    
  2. Copy the content of id_dsa.pub file and append it to the target machine's .ssh/authorized_keys file. If authorized_keys file is not accessible, then just create .ssh/authorized_keys2 file and paste the key.

    cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
    
  3. Copy the key to the target machine

    ssh-agent sh -c 'ssh-add < /dev/null && bash'
    
Share:
9,357
user962206
Author by

user962206

Updated on September 18, 2022

Comments

  • user962206
    user962206 over 1 year

    I was cloning a Git repository and I had copied my id_rsa key from another PC to my /home/me/.ssh/ on Ubuntu 12.04, however this error shows up:

    Permission denied (publickey,gssapi-with-mic).

    How would I solve this issue?

    • terdon
      terdon almost 11 years
      Don't copy the key file directly, use ssh-copy-id instead.
  • user962206
    user962206 almost 11 years
    I don't see any authorized_keys under my .ssh folder. should I make it?
  • Flup
    Flup almost 11 years
    Yes, that file has to exist and contain your trusted public key(s).
  • Flup
    Flup almost 11 years
    Ah! I've just realised what you're trying to do. OK, so it looks like you've done the right thing, and your problem might be permissions. Make sure that the keys, and the .ssh directory, are only readable by you.
  • user962206
    user962206 almost 11 years
    what about may old ssh key? will I still be use it?
  • user962206
    user962206 almost 11 years
    how would I do that?
  • Flup
    Flup almost 11 years
    cd /home/me; chmod 700 .ssh; chmod 600 .ssh/id_rsa .ssh/id_rsa.pub
  • user962206
    user962206 almost 11 years
    I just typed the code you have given should I expect any outputs? I tried running git again however the error still exists