0

I have a remote server with a git repository ready to be cloned... The problem is that I need to access that server using ssh with a key file authentication that i have saved on my local machine...

I've created an empty local folder and I make:

git clone ssh://username@45.645.465.12:/path_to_my_rep/.git

But, of course, I am getting a permission denied error.. How can I say to git where to pick my ssh key file???

I have tried creating a conf file on ~/.ssh/conf and adding this lines:

Host 45.645.465.12
    Hostname 45.645.465.12
    IdentityFile    ~/.ssh/myKeyFile.pem
    IdentitiesOnly yes

But I am getting this error:

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

Please make sure you have the correct access rights
and the repository exists.
Rodriguez David
  • 541
  • 9
  • 25

2 Answers2

0

If you've already generated a key-pair, you need to provide your public key to git server admin so that it gets added to authorized keys list. The key should be appended to authorized_keys file inside .ssh/ dir.

frennky
  • 12,581
  • 10
  • 47
  • 63
0

I updated my conf file under ~/.ssh/ and it looks like this:

Host myhost
    User myUser
    IdentityFile /path_to_my_key_file

My main mistake was that i was running git clone as root and because of that openSSH was not reading my conf file under home/user/ but under /root/...

After correcting this 2 things git clone worked just fine :)

Rodriguez David
  • 541
  • 9
  • 25