0

Can't see any posts that address this specific question so here goes...

I have a git repo on a vps. the repo tracks a website (contained in public_html) and also directories needed by that website (i.e. private, tmp, etc.). Like this:

    drwxr-xr-x  8 someuser someuser 4096 Jan 17 07:00 .git/
    drwxrwx---  5 someuser www-data 4096 Jan 17 07:00 private/
    drwxr-x--- 10 someuser www-data 4096 Jan 17 07:00 public_html/
    drwxrwx---  2 someuser www-data 4096 Jan 17 07:00 tmp/

as such, this repo is above the web root, not publicly accessible. ssh with key only access is set up on this linux system.

I want to clone this remote git repo via ssh to my local machine. How?

I have tried git clone ssh://user@ipaddress:22/path/to/repo . but I get:

    Cloning into '.'...
    Permission denied (publickey).
    fatal: Could not read from remote repository.

I don't understand why this is because my ssh config file correctly specifies the IdentityFile and Hostname and normal ssh works fine with these settings.

Any ideas? Thanks.

penname
  • 75
  • 2
  • 7
  • Just for curiosity: Is your public key stored on the linux server? – ckruczek May 17 '16 at 12:13
  • Have you looked at this http://stackoverflow.com/questions/4565700/specify-private-ssh-key-to-use-when-executing-shell-command-with-or-without-ruby ? – Peter May 17 '16 at 12:23
  • Add the public SSH key from your local machine to the VPS. – Oldskool May 17 '16 at 12:38
  • @ckruczek yes :) that's how i can connect via ssh in the first place. thanks. – penname May 17 '16 at 13:09
  • @Peter i tried the suggested solutions on that page without success. i will try again and document the error messages. – penname May 17 '16 at 13:09
  • @Oldskool as i said, "my ssh config file correctly specifies the IdentityFile and Hostname and normal ssh works fine with these settings"; i.e. the .pub key is already on the remote machine. – penname May 17 '16 at 13:10

1 Answers1

0

Setting the environment variable GIT_TRACE to something else than 0 will make git output the expansion of aliases, and delegation to other sub-programs.

This will allow you to see the exact command git uses to ssh to your remote machine.

In any case, here, the message is pretty clear: Permission denied (publickey). This comes from ssh for sure, so if a normal ssh works fine, you need to find the difference between what you call a normal ssh and, the ssh that git is executing.

smaftoul
  • 2,375
  • 17
  • 14
  • yes, i agree - the message is clearly coming from ssh. i'll investigate further and see what i can find. thanks. – penname May 17 '16 at 13:12
  • To further debug things, you can set the GIT_SSH_COMMAND environment variable to something like "ssh -vvv" so ssh will be verbose (I think it needs the GIT_TRACE to see the output, but not sure). This is also doable via your `~/.ssh/config` with "Host ipaddress\n LogLevel DEBUG3" as the content of the config. – smaftoul May 17 '16 at 13:19