1

I set ./git/config file like this.

[remote "origin"]
    url = https://github.com/haradashinya/dotfiles.git

It's pushed my github's repository but it asks for my username and password. So, I set my url to ssh style, like this:

url = git@github.com:haradashinya/dotfiles.git

But it outputs an error message saying 'Permission denied (publickey)'.

Why this happened?

nobinobiru
  • 792
  • 12
  • 28

3 Answers3

1

Even if you have defined ssh keys, you need to be sure HOME is defined (which isn't the case on Windows for instance, unless you are using a DOS session from git-cmd.bat shipped with msysgit): see "Trying to “install” github, .ssh dir not there".

In that same HOME directory, you could also record your https GitHub credential (username and password) if you still want to use the https address: see "change github account mac command line" for an example.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

You need to add your SSH key to your github account here: https://github.com/settings/ssh

If you haven't generated an SSH key, or you don't know how to generate an SSH key, or you don't understand how to add it to your github account, github provides detailed instructions here: https://help.github.com/articles/generating-ssh-keys

rob mayoff
  • 375,296
  • 67
  • 796
  • 848
0

I've followed with https://help.github.com/articles/error-permission-denied-publickey instructions.

And I resolved my problem by ssh-add 'my-id-rsa-path' command.

ssh-add ~/.ssh/id_rsa; ssh -vT git@github.com #-> success!

Thanks for help!

nobinobiru
  • 792
  • 12
  • 28