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?

  • Don't copy the key file directly, use ssh-copy-id instead. – terdon Jun 19 '13 at 13:34
  • after that? should I do? – user962206 Jun 19 '13 at 13:37

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'
| improve this answer | |
  • ssh-copy-id does the same thing: once the key is in place, you can just ssh-copy-id username@host. – Flup Jun 19 '13 at 13:59
  • what about may old ssh key? will I still be use it? – user962206 Jun 19 '13 at 13:59

You need to put the contents of id_rsa.pub in the file /home/me/.ssh/authorized_keys.

id_rsa is your private key and should be protected carefully.

| improve this answer | |
  • I don't see any authorized_keys under my .ssh folder. should I make it? – user962206 Jun 19 '13 at 13:31
  • Yes, that file has to exist and contain your trusted public key(s). – Flup Jun 19 '13 at 13:42
  • how would I do/create that? I don't know the format – user962206 Jun 19 '13 at 13:45
  • Just copy id_rsa.pub from the client machine to the server, and rename it as /home/me/.ssh/authorized_keys. – Flup Jun 19 '13 at 13:47
  • I have no access to the server.I just did a fresh install of ubuntu. and copied the id_rsa and id_rsa.pub from my windows 7 machine to ubuntu. – user962206 Jun 19 '13 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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