mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-09 12:46:42 -05:00
Migrate from SSH #675
Open
opened 2025-11-02 03:32:44 -06:00 by GiteaMirror
·
56 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.16.1
v1.16.0
v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2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#675
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @RickZeeland on GitHub (Apr 28, 2017).
[x]):Description
We have a GIT server which only supports SSH for cloning, not HTTP, example:
ssh://rick@123.45.6.7/source/test.git
How can I migrate a repository in Gitea ?
Or is there some other way I can do this manually ?
@sapk commented on GitHub (Apr 28, 2017):
You have multiple choice :
There must also be others methods to do it but they should be the easy one.
@RickZeeland commented on GitHub (Apr 28, 2017):
@sapk : Thanks for your tips, but I already tried the Migrate form in Gitea, it does not accept SSH url's.
I have been struggling the whole day trying to find a way to clone and merge the repository, but to no avail. In theory it seems to be possible to merge from another remote repository, but I can not get it working. Copying the files and checking them in is not really an option, as this would mean loosing the tags history.
@sapk commented on GitHub (Apr 28, 2017):
Have you try replacing ssh:// url part with git:// ?
@deanpcmad commented on GitHub (Apr 28, 2017):
@RickZeeland how many repos do you want to transfer over? What you could do is just clone them and push them to your Gitea server
The
git push --tagscommand will push all your tags@RickZeeland commented on GitHub (Apr 29, 2017):
@sapk : Thanks, I will try that out first next week when I'm at work again.
@deanpcmad : Looks good, It's only for one big repo. I tried something like you suggested locally with drive paths but got an error when pushing, had to go through some hoops to get it working:
git config --global receive.denyCurrentBranch ignoreGit gui - Repo1 - push to Repo2Git gui - Repo2 - visualize all branch history - r-click on revision -reset master branch to here - Reset type: hard@RickZeeland commented on GitHub (May 1, 2017):
@sapk : Nope, git: does not work.

@deanpcmad : It works like a charm, as long as you have a bare Gitea repository, see attached picture. Thanks !
@RickZeeland commented on GitHub (May 15, 2018):
@hetykai I have not read anywhere that this has been fixed, so I'm afraid you will have to do it from Bash with GIT commands like shown above.
Example as shown by @deanpcmad :
git clone user@1.1.1.1:abc/123.git cd 123 git remote set-url origin git@gitea-server.com:org/repo.git git push origin master git push --tags@RickZeeland commented on GitHub (May 15, 2018):
@hetykai it could also have to do with the SSH configuration which is typically found in: C:\Projects\Gitea\custom\conf\app.ini
How to config SSH settings
https://discuss.gogs.io/t/how-to-config-ssh-settings/34
https://docs.gitea.io/en-us/config-cheat-sheet/
@pgodwin commented on GitHub (Jun 28, 2018):
Any updates on this one? I've configured the SSH key on my user profile, but it doesn't seem to work properly with a git url. ie
git://bitbucket.org:user/repo.gitI get the following error:
@techknowlogick commented on GitHub (Jun 28, 2018):
@pgodwin as of now HTTP(S) is still the only way to mirror/migrate git repos from other systems
@BNolet commented on GitHub (Nov 3, 2018):
I'm confused, is this a conversation of the git:// URL prefix or not? If not, let me know so I can start an issue. Currently getting unable to connect and connection timed out
@RickZeeland commented on GitHub (Nov 4, 2018):
@BNolet No this is not a conversation of the git:// URL prefix. Don't think anything has changed and it's still not possible to migrate from SSH in Gitea, the documentation at https://docs.gitea.io/en-us/ only mentions: "Clone with SSH/HTTP/HTTPS".
@stale[bot] commented on GitHub (Jan 4, 2019):
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
@stale[bot] commented on GitHub (Mar 6, 2019):
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
@BNolet commented on GitHub (Mar 6, 2019):
Still an issue
@ShoelaceMan commented on GitHub (Mar 14, 2019):
Hey,
I'm seeing this as well, I think that it mostly has to do with being unable to specify a key to clone with, as if you import from an https:// link initially, and then edit the upstream url afterwards, it allows you to change it to an ssh:// link, but it gets permissions denied.
@6543 commented on GitHub (May 22, 2019):
what is the current state?
@lafriks commented on GitHub (May 25, 2019):
Noone is currently working on this
@kyozhou commented on GitHub (Jun 6, 2019):
it also confuse me
@halsafar commented on GitHub (Jun 20, 2019):
This is blocking evaluating Gitea for work. We cannot import our repo which is SSH+Keys only. The fact file:/// is also blocked seems silly to me. Basically we have no path to migrate.
@techknowlogick commented on GitHub (Jun 20, 2019):
@halsafar It is possible to import for disk. This is disabled by default for security reasons.
@halsafar commented on GitHub (Jun 20, 2019):
Thanks for the very quick response. How can I go about enabling that temporarily to import our repo?
@techknowlogick commented on GitHub (Jun 20, 2019):
@halsafar look for
IMPORT_LOCAL_PATHSdocumentation on this page: https://docs.gitea.io/en-us/config-cheat-sheet/ you can put the path directly, I don't think you needfile://prefix@halsafar commented on GitHub (Jun 20, 2019):
@techknowlogick Thank you very much for the quick response! I have successfully imported our repo.
@fzwoch commented on GitHub (Sep 10, 2019):
I wish for that feature too. It is not so much about migrating, but using the mirror functionality. I would like to have a mirror of a couple of remote repositories which are quite big, but low bandwidth connected on my Gitea instance. Due to the nature of password expire policies the mirror credentials often need to be updated to new passwords. This is some "maintenance" effort I would like to avoid by having SSH keys for authentication.
@sebathi commented on GitHub (Oct 16, 2019):
Also if more than one user is using gitea mirror repository both will see the password used for this on the administration side of the configuration.
@zeripath commented on GitHub (Oct 16, 2019):
It's extremely difficult to do this safely, securely and without it being a huge task.
I guess a blanket app.ini option of allow mirroring with SSH could work but the use of it would have to be highly discouraged and it would have to rely on default behaviour of SSH - users would have to manage the .ssh/config
But this is hardly a robust solution.
You'd really want more granular control and perhaps even a way of generating keys on Gitea which would then provide the user with a public key to put on their server.
@lunny commented on GitHub (Oct 17, 2019):
We need a new infrastructure maybe named secrets to store all private data.
@Sofianio commented on GitHub (Apr 19, 2020):
We really need this functionality
We have a lot of projects accessible via ssh only and we need this in order to fully transfer to Gitea
@6543 commented on GitHub (Apr 19, 2020):
@Sofianio you always can clone the whole repo to a PC and push to Gitea afterwards If you need it now :)
but this feature would be very usefull 👍
@Sofianio commented on GitHub (Apr 20, 2020):
@6543 we have a lot of projects ... that would be tedious
but i'm afraid it's the only way since this issue has been around for 3 years
@6543 commented on GitHub (Apr 20, 2020):
you could write a script witch do the work for you - but this should be discusted outside this issue beacues it is off topic
@Sofianio commented on GitHub (Apr 20, 2020):
A script would be great if there was a way to create organizations and repositories then pull/push to them
But if we have to create the orgs & repos from GUI then it's still tedious
@mcnesium commented on GitHub (Apr 20, 2020):
@Sofianio as I got to know here you can set
ENABLE_PUSH_CREATE_ORGandENABLE_PUSH_CREATE_USERto true in your config, and then just go ahead and push, e.g. like this:@Sofianio commented on GitHub (Apr 20, 2020):
Thanks :)
@penguinairlines commented on GitHub (Jun 27, 2020):
Hi, I am having this issue also. I discovered Gitea today while searching for a way to create a repository mirror to use as a backup. I am surprised to see it lacking the ssh pull method, as GitHub will stop supporting basic authentication on November 13, 2020 at 04:00 PM UTC. Is there any plan to allow us to use tokens to authenticate and support the ssh protocol?
I skimmed through and only see workaround suggestions, but these would not solve the mirror solution that I am looking for, which I see 3 other people mention over the past 2 years.
@lunny commented on GitHub (Jun 27, 2020):
I think this is blocked by #12065
@TheoLassonder commented on GitHub (Jul 25, 2020):
We'd really like to be able to do this also. We have a bunch of repos where the primaries are on various servers, and we'd like a mirror in Gitea.
I'm not sure why this is blocked by #12065 because it should work just fine if the user running Gitea can SSH to the remote servers where the repos are mirrored from (using an SSH key without password - no configuration required in Gitea at all).
@TheoLassonder commented on GitHub (Jul 25, 2020):
Was just curious, and just had a go at hacking Gitea to support mirroring using password-less SSH. And it worked! The trouble is, I don't know much (or anything) about Go, so I mainly just commented stuff out that prevented the URL from being accepted until Gitea just went ahead and treated it as a plain Git migration. And that does work!
@TheoLassonder commented on GitHub (Jul 25, 2020):
@zeripath It seems allowing SSH has similar security characteristics as allowing local file repos to be imported/mirrored. So it could be treated in the same way, that is, disabled by default but with a config parameter to allow it. It would help some people (including us) who now have to hack around this limitation using a local file mirror + a cron job to periodically update the local file mirror using SSH :-(
@TheoLassonder commented on GitHub (Jul 26, 2020):
In fact, looking more closely at the changes needed to support it, it's down to a one line change: to accept the ssh:// as a valid URL, along with http://, https://, and git://.
Other than that, of course some text in the UI would need to be updated and some documentation as well.
Is there any interest in me creating a patch and push request for this?
@6543 commented on GitHub (Jul 26, 2020):
@TheoLassonder feel free to create a pull 👍
@mateusza commented on GitHub (Feb 27, 2021):
What about using following workflow to allow SSH key-based authentication for repository migration/mirroring:
@lunny commented on GitHub (Mar 4, 2021):
@mateusza That's what #12065 to do. It will store all users' secrets include private key.
@ansemjo commented on GitHub (Aug 7, 2021):
Since #16437 is closed / merged with this one, I'll try to summarize my thoughts on this feature here.
I think it would make sense to split the issue of SSH migration or mirroring into two parts:
ssh://protocol in general, with username and password authentication or system keysIf I understand correctly, the first part is what #12397 is about. To be fair, I had not thought about this issue:
However, a) the further comments suggest that there are workarounds to prevent
gitfrom using the default keys – if any – in~/.ssh/of the Gitea user. And b) I don't think it is that much of a risk, to be honest, since placing keys into~/.ssh/of the Gitea user is a very conscious thing to do. If you feel it is a risk, then just don't generate any keys? Furthermore, in my selfhosted GitLab it always "just worked" to configure passwordlessssh://mirroring, which would use the git user's available keys (as I described here). And GitLab certainly does not cater only to small users, so how much of an issue can this really be? Regardless, maybe this could then be a flag – whether to allow Gitea to use available keys or not?Personally, I don't really see any issue that prevents supporting the
ssh://protocol with username and password / token at this point, similarly to howhttps://is already supported .. Simply being able to allow Gitea to use available keys would already cover my use-case for this feature without needing to enable custom git hooks, which I see as a much greater risk. To this end, I share @TheoLassonder's sentiment above, that the protocol support should not be blocked by #12065.Secondly, about the key storage. I don't think entropy is really a problem, since you really wouldn't be generating new keys very often. And unless you're on a tiny embedded platform with a readonly filesystem, even frequent key generation should not be a real problem today.
Generating (deploy) keys per repository and storing them in the database should also be reasonable. I haven't looked at the database model yet, and I havent looked at the work in #14483. But you're storing the secret token for
https://mirroring per-repository somewhere as well, after all. In this context, both tokens and per-repo private keys have very similar scopes, don't they?Even if you don't want to deal with managing keys on-disk somewhere, you could maybe use Go's crypto/ssh/agent to directly load the private keys from the database into an agent and pass that to the
gitprocess to use?I just stumbled upon this issue earlier today and I have only been using Gitea for a couple days now, so please excuse me if I have overlooked something. But the
ssh://protocol does appear to be a very sought-after feature and I was suprised that Gitea does not support it currently, so I wanted to summarize what I found regarding this feature so far.@uPagge commented on GitHub (Dec 11, 2022):
It's a pity that ssh is not supported yet :(
I wanted to push a mirror using ssh, but apparently this is not possible
@karolyi commented on GitHub (Mar 17, 2023):
+1, this option would be nice to have.
@synsa commented on GitHub (Mar 21, 2023):
+1, this as well. My company will only allow ssh:// for dealing with repos so being able to mirror push via ssh:// would be beneficial in allowing us to more widely adopt gitea over our internal git-web instance 😢
@jaketothepast commented on GitHub (Apr 25, 2023):
I just hit this issue when trying to setup an SSH mirror to Github. Is there any WIP? I'd be happy to lend a hand
@ansemjo commented on GitHub (Apr 25, 2023):
Since a lot of people seem to be finding this issue, I'll just copy verbatim my workaround from https://github.com/go-gitea/gitea/issues/16437#issuecomment-894641666:
I want to mirror a number of repositories to my GitHub account and don't want to create separate keys / tokens for each. So this is how I am currently doing it:
git/giteauser and generate a new key, e.g. withssh-keygen -t ed25519 -C "gitea mirroring" -f ~/.ssh/id_ed25519 -N ""ssh git@github.comonce to accept the hostkey and make sure GitHub recognizes your keypost-receivehook to repositories:Since I had quite a few of those repositories and I also wanted to have the option to skip mirroring on certain pushes, I expanded on the above and saved the following script in
/usr/local/bin/github-mirror:Use it in a
post-receivehook like:If your Gitea repository has the same name as the GitHub repository, you can just reuse the same snippet, because
$GITEA_REPO_NAMEis filled in when executing the hook.You can skip mirroring on a push with a
--push-option=skipmirror:Note that I would still count this as a workaround ... but it has worked reliably for me.
@jaketothepast commented on GitHub (Apr 25, 2023):
Thanks @ansemjo!
I'll gladly attempt a proper fix, or see if I can take over existing WIP to bring in this feature. Highly motivated now that I'm facing it
@blackshot commented on GitHub (Sep 22, 2023):
still an issue
@mgite commented on GitHub (Dec 12, 2024):
I wanted to mirror repository using ssh and pubkey, when i found out that n 2024 gitea does not support it i was very disappointed. Is supporting this ongoing process or has it been decided to not support this feature at all?
@borokhov-os commented on GitHub (Jul 2, 2025):
The suggestions above work for pushing, but what about pulling? Gitlab supports this…
@hramrach commented on GitHub (Jul 4, 2025):
After trying out various forges and https my impression is that https imposes arbitrary limits that may be fine for incremental updates but cause failure for initial mirroring of moderately sized repositories (eg. Linux kernel).
With that https as the only mirroring option is not acceptable. It does not actually work.
@techknowlogick commented on GitHub (Jul 19, 2025):
I have a PR for this here: https://github.com/go-gitea/gitea/pull/35089