redrabbit / git.limo

A Git source code management tool powered by Elixir with easy installation & high extensibility.
https://git.limo
MIT License
497 stars 42 forks source link

SSH Server shutdowns with ''No host key available' on MacOS Mojave #63

Closed ghost closed 5 years ago

ghost commented 5 years ago
/tmp/gitgud/ mix test                     
==> gitrekt
==> gitrekt
** (Mix) Could not start application gitgud: GitGud.Application.start(:normal, []) returned an error: shutdown: failed to start child: GitGud.SSHServer
    ** (EXIT) 'No host key available'

Is this something I could look into, getting it to generate a test keyfile as part of the test suite or is there a manual procedure which is usually followed?

redrabbit commented 5 years ago

Is this something I could look into, getting it to generate a test keyfile as part of the test suite or is there a manual procedure which is usually followed?

Generating SSH host keys is something you must do manually. You must generate the key once. It is configured in both :dev and :test environment to point to the same path.

It's actually explained in README.md:

In order to provide SSH as a Git transport protocol, you must generate a valid SSH public key for the server:

ssh-keygen -t rsa -f apps/gitgud/priv/ssh-keys/ssh_host_rsa_key

I would not bother automating this. For me, it belongs to the few setup steps you must run when installing the project, such as running mix ecto.setup...

ghost commented 5 years ago

It fails on my machine, either with or without adding via ssh-add :

Without ssh-add :

/tmp/gitgud/ ssh-keygen -t rsa -f apps/gitgud/priv/ssh-keys/ssh_host_rsa_key
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in apps/gitgud/priv/ssh-keys/ssh_host_rsa_key.
Your public key has been saved in apps/gitgud/priv/ssh-keys/ssh_host_rsa_key.pub.
The key fingerprint is:
SHA256:FBAC1FO140gUOLweiJ6sgHfQFseOtwZLI/0xWRFZoJ8 b@nenavishu
The key's randomart image is:
+---[RSA 2048]----+
| .o+.+*=**.      |
|    Boo.oo       |
| . + Ooo+        |
|. + @.*= o       |
|+ .* B.+E        |
|o+. + +          |
|o. . .           |
|.                |
|                 |
+----[SHA256]-----+
/tmp/gitgud/ mix deps.get && mix test
Resolving Hex dependencies...
Dependency resolution completed:
Unchanged:
  absinthe 1.5.0-beta.2
  absinthe_phoenix 1.5.0-alpha.0
  absinthe_plug 1.5.0-alpha.0
  absinthe_relay 1.5.0-beta.0
  argon2_elixir 2.0.5
  bamboo 1.3.0
  benchee 1.0.1
  certifi 2.5.1
  combine 0.10.0
  comeonin 5.1.2
  connection 1.0.4
  cowboy 2.6.3
  cowlib 2.7.3
  db_connection 2.1.1
  decimal 1.8.0
  deep_merge 1.0.0
  earmark 1.4.0
  ecto 3.2.0
  ecto_sql 3.2.0
  elixir_make 0.6.0
  ex_doc 0.21.2
  faker 0.12.0
  file_system 0.2.7
  gettext 0.17.0
  hackney 1.15.1
  idna 6.0.0
  jason 1.1.2
  makeup 1.0.0
  makeup_elixir 0.14.0
  metrics 1.0.1
  mime 1.3.1
  mimerl 1.2.0
  nimble_parsec 0.5.1
  oauth2 2.0.0
  parse_trans 3.3.0
  phoenix 1.4.10
  phoenix_ecto 4.0.0
  phoenix_html 2.13.3
  phoenix_live_reload 1.2.1
  phoenix_pubsub 1.1.2
  plug 1.8.3
  plug_cowboy 2.1.0
  plug_crypto 1.0.0
  postgrex 0.15.0
  ranch 1.7.1
  ssl_verify_fun 1.1.4
  telemetry 0.4.0
  timex 3.6.1
  tzdata 1.0.1
  unicode_util_compat 0.4.1
==> gitrekt
==> gitrekt
** (Mix) Could not start application gitgud: GitGud.Application.start(:normal, []) returned an error: shutdown: failed to start child: GitGud.SSHServer
    ** (EXIT) 'No host key available'

Or (with ssh-add) :


/private/tmp/gitgud/ ssh-add apps/gitgud/priv/ssh-keys/ssh_host_rsa_key
Identity added: apps/gitgud/priv/ssh-keys/ssh_host_rsa_key (b@nenavishu)
/private/tmp/gitgud/ mix deps.get && mix test
Resolving Hex dependencies...
Dependency resolution completed:
Unchanged:
  absinthe 1.5.0-beta.2
  absinthe_phoenix 1.5.0-alpha.0
  absinthe_plug 1.5.0-alpha.0
  absinthe_relay 1.5.0-beta.0
  argon2_elixir 2.0.5
  bamboo 1.3.0
  benchee 1.0.1
  certifi 2.5.1
  combine 0.10.0
  comeonin 5.1.2
  connection 1.0.4
  cowboy 2.6.3
  cowlib 2.7.3
  db_connection 2.1.1
  decimal 1.8.0
  deep_merge 1.0.0
  earmark 1.4.0
  ecto 3.2.0
  ecto_sql 3.2.0
  elixir_make 0.6.0
  ex_doc 0.21.2
  faker 0.12.0
  file_system 0.2.7
  gettext 0.17.0
  hackney 1.15.1
  idna 6.0.0
  jason 1.1.2
  makeup 1.0.0
  makeup_elixir 0.14.0
  metrics 1.0.1
  mime 1.3.1
  mimerl 1.2.0
  nimble_parsec 0.5.1
  oauth2 2.0.0
  parse_trans 3.3.0
  phoenix 1.4.10
  phoenix_ecto 4.0.0
  phoenix_html 2.13.3
  phoenix_live_reload 1.2.1
  phoenix_pubsub 1.1.2
  plug 1.8.3
  plug_cowboy 2.1.0
  plug_crypto 1.0.0
  postgrex 0.15.0
  ranch 1.7.1
  ssl_verify_fun 1.1.4
  telemetry 0.4.0
  timex 3.6.1
  tzdata 1.0.1
  unicode_util_compat 0.4.1
==> gitrekt
==> gitrekt
** (Mix) Could not start application gitgud: GitGud.Application.start(:normal, []) returned an error: shutdown: failed to start child: GitGud.SSHServer
    ** (EXIT) 'No host key available'
redrabbit commented 5 years ago

This is kind of weird. I did remove my ssh_host_rsa_key and ssh_host_rsa_key.pub keys from apps/gitgud/priv/ssh-keys.

When generating the key pair with ssh-keygen -t rsa -f apps/gitgud/priv/ssh-keys/ssh_host_rsa_key, I got the same error.

There appears to be a change in the default key file format in OpenSSH_7.8p1 and later. MacOS Mojave 10.14.2 ships with OpenSSH_7.9p1.

The new format looks as follow:

-----BEGIN OPENSSH PRIVATE KEY-----  

In order to generate the key pair in PEM format, one must pass the -m PEM option:

ssh-keygen -m PEM -t rsa -f apps/gitgud/priv/ssh-keys/ssh_host_rsa_key

Will update the README.md accordingly.

redrabbit commented 5 years ago

Closing this

rogerpinho commented 4 years ago

Hey, I am facing the same issue in Ubuntu 18.04, I generate the ssh keys with ssh-keygen -m PEM -t rsa -f apps/gitgud/priv/ssh-keys/ssh_host_rsa_key, I got this:

(Mix) Could not start application gitgud: GitGud.Application.start(:normal, []) returned an error: shutdown: failed to start child: GitGud.SSHServer
     (EXIT) 'No host key available'
ssh -V                                      
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017