Mirroring from an ssh repo source


We are trying to migrate from gitolite on one server, to gogs on another. Our gitolite server is accessed through ssh, but the gogs repo mirror doesn’t support ssh sources.

I have set up an ssh key and config alias, such that if I am the gogs user on the gogs server, I can:
git clone gitolite:repo-name
…and it will use the correct ssh key and host alias to access our gitolite repo.

Is there any way to use this to set up a mirrored repo from gitolite to gogs?

I tried creating a normal Gogs repo, then replacing it with a “git clone --mirror” copy at the filesystem level, and while the structure looked similar, gogs did not reflect the files that were now available in the replaced repo.



I haven’t tried this, but maybe try to give the git user of gogs its own ssh key (passwordless) and allow that key access to your gitolite repo?


Yep, that’s what I tried, and I can confirm it’s working from the command line. I have it set up so that from the “gogs” server, I can connect to “gitolite”, which via ssh config, translates to the user, host & key of the gitolite service.

So, this works from the command line:
git clone gitolite:testing testing.git

However, I can’t put “gitolite:testing” into the Gogs Migration, as it thinks it’s just a local path, rather than a git ssh address. I also tried creating a normal Gogs new repo, then at the filesystem removing it and replacing it with a git --mirror, and it didn’t seem to pick it up either.

I can clone the mirror repo from Gogs, and see the mirrored files - but the Gogs UI still shows the repo is empty.

Aha! The placeholder repo had an “update” hook!

I copied the hooks/update into the manual mirror clone, and after an update, Gogs is now showing the manually mirrored repo.


Ok - the hooks/update helps if you manually push changes into the repo, but it doesn’t seem to be triggering when the mirror update happens. (ie; not needed and pointless for the goal of just mirroring)

I have found there’s a simpler way to set up a mirror repo, with an ssh source:

  • Create a migration/mirror repo, using a local empty repo (eg; mkdir /tmp/dummy; cd /tmp/dummy; git init then use /tmp/dummy)
  • Go into the repo settings, and change the “Mirror Address” to your gitolite:repo-name real source via ssh

…and when Gogs does its mirroring, it does seem to fetch from the source - but it’s not reflected in the Gogs GUI (still shows the empty repo “how to start” screen). I can go into the repo from the command line and see the full log of the mirrored repo though, so it is fetching.

Why the Gogs GUI doesn’t show the mirrored repo content I have yet to figure out…


Migrate via SSH I think is not supported…


Hi Unknwon,

Migrate via SSH does work though. The problem is you can’t enter an SSH URL in the “Clone Address” in the initial migration page (at /repo/migrate) because it thinks it’s an invalid local URL. However, if you set it to an empty local repo, and then edit the “Mirror Address” under /org/repo/settings and put the SSH URL in there - it works!

As a work-around, this is reasonable - however, there is one additional problem. While the repo does get mirrored, the Gogs interface remains on the blank repo view. To get around this, I had to manually update the repository table and set is_bare to 0. Then, the full Gogs Repo UI works.


That’s… a good trick!


Dortamur’s trick seems to be working, but I can’t figure out where to store the target SSH server’s public key.

Gitea runs on M$-Windows, locally I’m able to clone the repository (I’ve acknowledged the public key manually). I use Gitea’s built-in SSH server with manually imported msys2, env, and ssh-keygen requirements.

I’ve tried to copy the known_hosts to:
[gitea user]/.ssh/known_hosts
[gitea binary location]/data/ssh/known_hosts
[gitea binary location]/data/ssh/known.hosts

But each time I run a repository update task, I get “Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. error: Could not fetch origin”.

@Unknwon: do you know where I should store it?