Unable to 'Detect host keys' when mirroring repo using SSH
Summary
When trying to set up a push mirror using SSH, both GitLab.com and externally hosted instances running in a GitLab Docker container are unable to detect host keys.
I have had an instance where this issue is not present using a locally hosted Docker instance, however it's inconsistent, other locally hosted instances also fail.
Steps to reproduce
- Choose a repository on GitLab.com, or create a repo to test.
- Go to the 'Mirroring repositories' section in the repository's settings.
- Insert a valid SSH URL into the 'Git repository URL' field.
- Click the 'Detect host keys' button.
What is the current bug behavior?
The 'Detect host keys' button will be greyed out. A spinner will appear briefly, then disappear. The 'Detect host keys' button will remain greyed out, but no fingerprints are displayed and no message is output to indicate that it failed.
What is the expected correct behavior?
Host fingerprints should be displayed in the .fingerprints-list
div below the 'Detect host keys' button.
Relevant logs and/or screenshots
Below logs are taken from an instance running locally in Docker, where the feature works as intended, and an instance running on an external server, where it doesn't (behaviour is identical to GitLab.com). GET
request in the locally hosted container returns a 200, in the externally hosted container it returns a 204; I'm presuming this will be the same for GitLab.com
Local:
/var/log/gitlab/gitlab-rails/production.log
Started GET "/root/test/mirror/ssh_host_keys.json?ssh_url=ssh://gitlab.com&compare_host_keys=" for 127.0.0.1 at 2019-01-24 09:55:53 +0000
Processing by Projects::MirrorsController#ssh_host_keys as JSON
Parameters: {"ssh_url"=>"ssh://gitlab.com", "compare_host_keys"=>"", "namespace_id"=>"root", "project_id"=>"test"}
Completed 200 OK in 12ms (Views: 2.5ms | ActiveRecord: 1.4ms)
/var/log/gitlab/gitlab-workhorse/current
2019-01-24_09:55:53.25385 MY_LOCAL_HOSTNAME 127.0.0.1:0 - - [2019/01/24:09:55:53 +0000] "GET /root/test/mirror/ssh_host_keys.json?ssh_url=ssh://gitlab.com&compare_host_keys= HTTP/1.1" 200 1026 "http://MY_LOCAL_HOSTNAME/root/test/settings/repository" "Mozilla/5.0 (X11; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0" 0.031
/var/log/gitlab/gitlab-rails/production_json.log
{"method":"GET","path":"/root/test/mirror /ssh_host_keys.json","format":"json","controller":"Projects::MirrorsController","action":"ssh_host_keys","status":200,"duration":12.93,"view":2.49,"db":1.43,"time":"2019-01-24T09:55:53.239Z","params":[{"key":"ssh_url","value":"ssh://gitlab.com"},{"key":"compare_host_keys","value":""},{"key":"namespace_id","value":"root"},{"key":"project_id","value":"test"}],"remote_ip":"DOCKER_CONTAINER_IP","user_id":1,"username":"root","ua":"Mozilla/5.0 (X11; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0","correlation_id":"8aXbEJFqN54"}
External:
/var/log/gitlab/gitlab-rails/production.log
Started GET "/root/test/mirror/ssh_host_keys.json?ssh_url=ssh://gitlab.com&compare_host_keys=" for MY_LOCAL_IP at 2019-01-24 09:56:55 +0000
Processing by Projects::MirrorsController#ssh_host_keys as JSON
Parameters: {"ssh_url"=>"ssh://gitlab.com", "compare_host_keys"=>"", "namespace_id"=>"root", "project_id"=>"test"}
Completed 204 No Content in 10ms (Views: 0.3ms | ActiveRecord: 1.1ms)
/var/log/gitlab/gitlab-workhorse/current
2019-01-24_09:56:55.13676 SERVER_IP MY_LOCAL_IP:0 - - [2019/01/24:09:56:55 +0000] "GET /root/test/mirror/ssh_host_keys.json?ssh_url=ssh://gitlab.com&compare_host_keys= HTTP/1.1" 204 0 "http://SERVER_IP/root/test/settings/repository" "Mozilla/5.0 (X11; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0" 0.027
/var/log/gitlab/gitlab-rails/production_json.log
{"method":"GET","path":"/root/test/mirror/ssh_host_keys.json","format":"json","controller":"Projects::MirrorsController","action":"ssh_host_keys","status":204,"duration":11.21,"view":0.35,"db":1.15,"time":"2019-01-24T09:56:59.252Z","params":[{"key":"ssh_url","value":"ssh://gitlab.com"},{"key":"compare_host_keys","value":""},{"key":"namespace_id","value":"root"},{"key":"project_id","value":"test"}],"remote_ip":"MY_LOCAL_IP","user_id":1,"username":"root","ua":"Mozilla/5.0 (X11; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0","correlation_id":"gImLmCyhM92"}
Output of checks
This bug happens on GitLab.com.