gogs: Cloning with SSH does not work (says repository doesn't exist)

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 git@xxx.xxx.xxx.xxx: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
git@xxx.xxx.xxx.xxx'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:

Link

It only works if I use the full path:

git clone git@xxx.xxx.xxx.xxx:~/gogs-repositories/overv/my-test-repo.git

How do I fix this?

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 47 (15 by maintainers)

Most upvoted comments

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 👍

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

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.

No problem 😃

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 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.