Reputation: 617
I can connect from my pc to my EC2 git server using ssh ( i specified port 22 cause default port is onother):
$ ssh -p22 [email protected]
this works fine, but when I try to clone I have som problems(again i specified port 22 cause default port is onother):
sudo git clone ssh://[email protected]:22/home/dev/some/stuff.git
this is the output:
[email protected]: Permission denied (publickey).
why????
Upvotes: -1
Views: 195
Reputation: 77004
The reason is because you're using sudo
. OpenSSH uses the public keys of the current user to log in, and when you use sudo
, they're the public keys of root
, not your normal user.
If you want to clone as root, you either need to set up keys for root or set a /root/.ssh/config
file that uses the normal user's keys via the IdentityFile
option. For example, if your normal user is example
and you're using an Ed25519 key, the file might look like this:
Host xxxxxxxxxx.compute.amazonaws.com
IdentityFile /home/example/.ssh/id_ed25519
Upvotes: 1