1

Running Ubuntu, in case that's relevant.

I already have a Github account, with my public key added, and I'm making a move from Windows to Ubuntu. I went through all the necessary steps to get my credentials setup, then (wisely) cloned a repo of mine into the .ssh directory. Everything worked fine, but...that's not where I want it to be, of course. So I removed the directory I cloned into, actually tried it from the directory where I wanted it to be, and I get:

rich@ubuntu:/opt/lampp/htdocs$ sudo git clone git@github.com:Polisurgist/introRecorder.git
Cloning into 'introRecorder'...
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

So for some reason it's able to use my key, but only when I'm cloning into the directory that contains my key. I'm sure I'm missing a step that tells git where to find the key, but I don't know what that step is.

Polisurgist
  • 340
  • 2
  • 11

1 Answers1

1

It is possible it worked the first time because ssh went looking for the public/private keys in the current folder.

But once you moved directories, ssh will look for those same keys in ~/.ssh/id_rsa(.pub).
So you need to make sure those keys are there, in the right place (should be /home/rich/.ssh), with the right protection (see "git push failing in gitlab").

Doing the git clone with a sudo will mean ssh would look for those keys in the root homedir, which isn't necessarily what you want.

/opt/lampp/htdocs: Can't create directory.

That means you need those keys in /root/.ssh, if you want the git clone to be done as root (see "Home folder in root and not in home… I'm confused!").
But you rather should create that folder as root and change its ownership, and then do the git clone as rich.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Yeah, that appears to be the problem. Of course, root is locked on Ubuntu, so I think I can't do that but I can just change permissions in my webroot. – Polisurgist Dec 07 '13 at 20:11