I am developing a git infrastructure testing purposes. One of the things I am trying to test is clone a bare git repo from an AWS Ubuntu server. is type in the flowing
git clone ubuntu@numbers.us-west-2.compute.amazonaws.com:/srv/git/Test_Git.git
I get the following response
Cloning into 'Test_Git'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
As the error says, your ssh access has been denied.
Some probable causes:
You are logging in as the user ubuntu
. Verify that this is the username you should be using.
Verify that the SSH key you are using to log in is configured on the remote user. It is normally in that user's $HOME/.ssh/authorized_keys
file.
Verify that the permissions on the server SSH files are correct. The authorized_keys file must not be writable by anyone but the owner. That is also true of every directory in the path leading up to that file. So for example that might mean you need to check the permissions on these paths (this may vary depending on the system and the user you are using).
/
/home/
/home/ubuntu/
/home/ubuntu/.ssh/
/home/ubuntu/.ssh/authorized_keys
The user you log in as must have read permission on the git repository in order to let you clone a copy of it. In this case, the path is
/srv/git/Test_Git.git/
That path, and everything under it, must be readable by the user that you are logged in as.
Ideally, that user should own that entire directory and all of its contents. Because you'll need that later when you (presumably) will want to push changes back to the server.
If none of the above solves the problem, assuming you can log into your server, check the system logs for an SSH error message.
The most common places to find SSH messages on Linux are
/var/log/messages
/var/log/secure
You can also get debug information from the client end, though this will only show you things the client is doing. If you want to be sure which key you are trying to use for login, this is how you would find it.
ssh -v ubuntu@numbers.us-west-2.compute.amazonaws.com