I've installed the latest version of Gogs on Ubuntu 14.04 using this guide. Checking out with HTTP works fine:
git@git-server:~$ git clone http://xxx.xxx.xxx.xxx/overv/my-test-repo.git
Cloning into 'my-test-repo'...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
Checking connectivity... done.
But when I try to clone with SSH, it will say the repository doesn't exist:
git@git-server:~$ git clone [email protected]:overv/my-test-repo.git
Cloning into 'my-test-repo'...
The authenticity of host 'xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx)' can't be established.
ECDSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Are you sure you want to continue connecting (yes/no)? yes
[email protected]'s password:
fatal: 'overv/my-test-repo.git' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
As you can see, I'm using the URL as given to me by Gogs:

It only works if I use the full path:
git clone [email protected]:~/gogs-repositories/overv/my-test-repo.git
How do I fix this?
Do you have your SSH key added?
In the current version gogs doesn't allow anonymous cloning over SSH. See: #1222
@matt-h My key is in /home/git/.ssh/authorized_keys. Do I need to add it somewhere in gogs as well?
Yes, you should not modify the authorized_keys file manually. You can add you key in your gogs profile at https://<domain>/user/settings/ssh
You can also have gogs clean up the authorized_keys file in the Admin section under Operations.
@Overv the problem is, gogs uses the key to determine which (gogs) user you are, which is what determines your repo access rights. So it's not just a matter of having access to the system, which is enforced by sshd via authorized_keys, but of access to the repo, which is enforced by gogs via the database.
I've added every SSH key on my local PC to Gogs and ran the command for rewriting .ssh/authorized_keys, but it still gives the same error.
$ git clone [email protected]:overv/my-test-repo.git
Cloning into `my-test-repo`...
[email protected]'s password:
fatal: `overv/my-test-repo.git` does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Nothing appears to happen on Gogs' side either:

The authorized_keys file looks correct:

Same: I've added my public key to both Gogo's SSH page and authorized_keys file (just in case) - but each time I try to clone a test repo, I get the following:
┬─[foo@bar:/tmp]─[05:39:25 PM]
╰─>$ git clone [email protected]:foo/test.git
Cloning into 'test'...
[email protected]'s password:
Permission denied, please try again.
[email protected]'s password:
Received disconnect from 192.168.45.2: 2: Too many authentication failures for git
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Cloning over HTTP is perfectly fine though.
nginx listens over port 3000. Would that matter when cloning over SSH? For example, in order for me to clone over HTTP, I have to specify:
┬─[foo@bar:/tmp]─[05:39:33 PM]
╰─>$ git clone http://192.168.45.2:3000/foo/test.git
@initbar just solved the same problem this morning. Are you using supervisor? If yes, make sure you have line 'user = git' in its config section.
If not using supervisor, than possibly your ssh auth file permission isn't 600.
@Unknwon Got it, I'll give it a try
Hi,
I have the same issue as the first post, I mean the ssh path provided in the web UI is not complete (without the root path provided in app.ini). So when I clone, it can't find the repository. If I add it manually when cloning, it is fine.
So I guess that Gogs doesn't handle the root path in the ssh clone command of the UI.
@captnbp Hi,
without the root path provided in app.ini
Without the root path is the correct form, don't you clone repo from GitHub just username and reponame?
If you have to have root path in order to clone, it means your SSH auth file has keys that are not from Gogs, which can be a big problem right now.
It happens when you first add that key for user login, then you add same one through Gogs, which in this case, the gogs one never got chance to match.
Oh OK I understand the philosophy ! So this is on purpose.
I have many keys in my authorized_keys file.
I removed my key in this file and now it works fine.
Thanks for the explanation !
@captnbp no problem!
It is actually quite a common problem(misunderstanding).
@Unknwon Woot! Your suggestion had fixed it!
Cheers!
@initbar good to know!
Close for now but open for continuing discussion.
For the record I misunderstood how this worked too. Solution was to let Gogs rewrite '.ssh/authorized_keys' file (via Admin Panel > Operations).
It makes sense how this routes RepoRootPath now :+1:
In principle you shouldn't manually touch anything at all in the gogs system user account.
Maybe we could make this clearer in the documentation?
Yes, I think it might be worth highlighting this _gotcha_ in the documentation.
Maybe a section on SSH under http://gogs.io/docs/installation/configuration_and_run?
:+1:
@gamb @lalomartins it has something said here: http://gogs.io/docs/intro/troubleshooting#git
@lab101 Please do following thing on admin dashboard:

Ah had done it before but know its working.
Sorry for this.
Now its working perfect love it!
No problem :)
I am still unable to clone any repository after following all these steps.
I have installed Gogs on a fresh Ubuntu 15.10 VM, added my SSH key to my account and ran rewrite in the admin panel, but it still says the repository does not exist.
I am running the latest binary from a folder in my Desktop using the sqlite backend as user account 'overv' with ./gogs web. When cloning, I get this:
$ git clone [email protected]:Overv/Test.git
Cloning into 'Test'...
[email protected]'s password:
fatal: 'Overv/Test.git' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I'll look into debugging this issue myself.
Edit: I fixed the problem, for some reason my client was not using any public key. (Using ssh to log in didn't work either.) I'm sorry for the confusion.
:trollface:
I am running gogs on a shared hosting where i only have one user.
I was intending to use the same public key for ssh and git/gogs.
The one for ssh was added before and is further up in .ssh/authorized_keys
This leads to gogs not identifying you.
The solutions is to generate a new ssh key and add this as your gogs key.
That bit me as well
I am also experiencing this issue, but I am running on windows with cygwin, I am unable to find an authorised_keys file in any of the user profiles on the system, and I have run the script from the UI many times. Like others, it works when I use the full path, which in my case looks something like [email protected]:e:/gogs-repositories/mjones/test.git because of windows full path.
is there anything else We should be looking at other then the keys in the authorized_keys file? Do you know where that file might be in cygwin? I am currently running as a service, and gogs appears to be funning under the computer account MYSERVER$
@radicalgeek you can set this value to the directory wherever contains the authorized_keys file.
Still the same behaviour. Gogs is running as local system, where as Cygwin sshd is running as cyg_server. I have tried pointing the SSH_ROOT_PATH at both C:\Users\MLCLUSTERVS108$.ssh and C:\Users\cyg_server.ssh. In both instances I can then run the rewrite authorised_keys job from the UI, and see the key in the .ssh directory of the user I point the path at. I noticed that there were 2 keys in here so I removed the top one. In both instances though it has not solved anything. I am still seeing the same behaviour. fatal: does not appear to be a git repository/fatal: Could not read from remote repository when run with relative path, and works fine when run with full path.
I am concerned I do not have the correct authorised_keys file though, as one did not exist in these directories until I pointed the SSH_ROOT_PATH though, but the job from the web UI would return a success, so where was it writing it before?
@radicalgeek I suggest you use built-in SSH server by setting this value: https://github.com/gogits/gogs/blob/master/conf/app.ini#L65
No, I am afraid that has not resolved it. With these settings..
[repository]
ROOT = E:/gogs-repositories
[server]
DOMAIN = mlclustervs108.ml.local
HTTP_PORT = 80
ROOT_URL = http://mlclustervs108.ml.local/
DISABLE_SSH = false
SSH_PORT = 22
OFFLINE_MODE = false
START_SSH_SERVER = true
SSH_ROOT_PATH = C:\Users\MLCLUSTERVS108$.ssh
and having disabled the Cygwin ssh service, I can connect to the box but then I get a permission denied followed by the same fatal message. It no longer works with the full path, and I have run the authorized_keys reset job from the UI. I have not changed my public key, nor reuploaded it to the UI.
mjones@MCS159 MINGW64 /c/Code
$ git clone [email protected]:mjones/test2.git
Cloning into 'test2'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
mjones@MCS159 MINGW64 /c/Code
$ git clone [email protected]:e:/gogs-repositories/mjones/test2.git
Cloning into 'test2'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
@radicalgeek
These are more system admin things than Gogs configuration.
But it is listening on 22, as the other service is not running and I am getting a response as you can see from the output? What do you mean "not allowed". So long as I don't have another service on this port....
I have rebooted the box, and the behaviour has not changed.
But it is listening on 22, as the other service is not running and I am getting a response as you can see from the output?
If that is the case, I think you did not add your public key to Gogs at all, that's why it declines.
no both my public keys (one for my macbook, and one for my laptop) are both still present in the UI. I have also removed them from the authorized_keys file, and run the job to re-add them.
I am going home for the day now. I need a working server by the end of the week, and I have been battling with this software since last week now. It's a real shame because it looks really nice, and has all the features I want if I could get it to work. I don't have the luxury of a Linux box to put this on, and it is supposed to work on windows.
If you have any further suggestions, I will have another go tomorrow. But at this point I think I am going to have to go with a competing product like git blit. Sorry.
Ok, I created a new key. I don't get the permission denied now, but nor will it clone the repo with either a relative or absolute path.
Please check logs from Gogs console.
Hummmmm. So it works fine when I run it in a console. It is only when it is running as a service that I am having the issue.
I tried running it from the console as both my domain user account, and a local account called gogs. It worked both times.
When I run as a service it runs under the local computer account. I tried switching it to the local gogs account by updating the app.ini and changing the service log on properties, but I still could not clone (could not read from remote repository) in that configuration.
So I could send you my console output but it would be pointless as it works fine in the console. I have left it running like that for now, but I would like to get it installed as a service properly.
just as a note, I tried to install it with nssm to run under the gogs account, but that gave me no joy either.
When I run as a service it runs under the local computer account. I tried switching it to the local gogs account by updating the app.ini and changing the service log on properties, but I still could not clone (could not read from remote repository) in that configuration.
@radicalgeek you need to check path/to/gogs/log/gogs.log see if any errors there.
I'm having exact the same issue as OP.
Cloning the new repository through SSH fails:
$ git clone [email protected]:atoss-csd/project.git
Klone nach 'project' ...
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
On gogs server's auth.log following messages are shown:
Apr 25 13:08:35 fangorn sshd[9623]: Accepted publickey for git from 192.168.49.29 port 51654 ssh2: RSA SHA256:anihi903KjBNwuy5CxqXRTIChXXevNW+wt+MKTxk350
Apr 25 13:08:35 fangorn sshd[9623]: pam_unix(sshd:session): session opened for user git by (uid=0)
Apr 25 13:08:35 fangorn systemd: pam_unix(systemd-user:session): session opened for user git by (uid=0)
Apr 25 13:08:35 fangorn systemd-logind[775]: New session 19 of user git.
Apr 25 13:08:35 fangorn sshd[9663]: Received disconnect from 192.168.49.29 port 51654:11: disconnected by user
Apr 25 13:08:35 fangorn sshd[9663]: Disconnected from 192.168.49.29 port 51654
Apr 25 13:08:35 fangorn sshd[9623]: pam_unix(sshd:session): session closed for user git
Apr 25 13:08:35 fangorn systemd-logind[775]: Removed session 19.
Apr 25 13:08:35 fangorn systemd: pam_unix(systemd-user:session): session closed for user git
Edit: A speciality might be that repository belongs to an organization and the cloning user is a member of this organization.
Edit 2: The hosting git user was a system user. Changing the login shell from /bin/false to /bin/bash allows cloning.
Just leaving this comment in case someone stumbles upon here. This issue is one of the first results on a "gogs ssh clone permission denied public key" google search and I had a tough time finding the solution to this particular problem.
My gogs is hosted on CentOS 7. I was having this error while cloning a gogs repo with ssh:
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I fixed it by setting UsePAM to yes on /etc/ssh/sshd_config. Set this option, restart the sshd service and you're good to go.
In my case simply my ssh agent was not running.
Ubuntu 16.04 after doing this and checking the keys are added it worked.
#Start SSH agent
if [ -z "$SSH_AUTH_SOCK" ] ; then
eval ssh-agent -s
ssh-add
fi
I was having the same issue, got it working by configuring like this:
cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = [email protected]:gogs-username/repo-name.git
fetch = +refs/heads/:refs/remotes/origin/
[branch "master"]
remote = origin
merge = refs/heads/master
[credential]
helper = store
now git push works without asking for password
Most helpful comment
For the record I misunderstood how this worked too. Solution was to let Gogs rewrite '.ssh/authorized_keys' file (via Admin Panel > Operations).
It makes sense how this routes
RepoRootPathnow :+1: