GrantJamesPowell

GrantJamesPowell

Having issues loading the `host_key` for BEAM ssh daemon

I’m a huge fan of the remote shell capabilities that elixir 1.9 added.

I’m working in an environment where I won’t be able to connect via BEAM node networking and would like to use the beam :ssh module to give a similar experience of elixir’s releases remote to my team.

I’m following the Erlang based examples here but I’m running into issues.
https://www.erlang-solutions.com/blog/secure-shell-for-your-erlang-node.html
http://erlang.org/doc/apps/ssh/users_guide.html

I’m running these on my Mac Mojave (10.14.6) with these Erlang/Elixir versions

Erlang/OTP 22 [erts-10.4.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]
Interactive Elixir (1.10.2) - press Ctrl+C to exit (type h() ENTER for help)

And this openssh version

➜  ssh -V
OpenSSH_7.9p1, LibreSSL 2.7.3

First I generate the keys (with no password)

mkdir ssh_dir
ssh-keygen -t rsa -f ssh_dir/ssh_host_rsa_key

Then I try to run this elixir code and its telling me that there is no host key available

iex(4)> :ok = :ssh.start()
:ok
iex(5)> :ssh.daemon(8989, system_dir: 'ssh_dir', password: 'foo')
{:error, 'No host key available'}

Then I try it in Erlang and get the same answer

2> ok = ssh:start().
ok
3> ssh:daemon(8989, [{system_dir, "ssh_dir"}, {password, "foo"}]).
{error,"No host key available"}

I was wondering if anyone had any insight on how to debug this issue.

(Here are the key files I’m using to debug. I am NOT using these keys anywhere, just to test the ssh module)

➜  cat ssh_dir/ssh_host_rsa_key.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTprdAtxwCexonmzP3qDvMvukg+n/cNr86mE0CkcnAzCjmfPZBW1ywy8RDfz06uXmUq02OlmioZ2OUR7fTK+ZViVkjrwyW232EoVNW2FnwHS//LPQsRuY3JZU9KCKhhRgNUK3elCY4jOARCuVi8dw3+vqnTkBNYkNXvJNkHcwcWwwja9kHi/ZbXpKuZCTaM1CGUB8cOrc90d5hdfNdYyh4yQf2+Zu3jOJPqHOqHD3T/Bw+a56fKx7wi4+EqAHVv42Pfk8FB05CFhvGHcn+0Imh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dg9i1fqrMdXMIaLgSyaqt506H3XF6PgOE96Dt5kU9Ng4K11SW8W6cXnAmixkdh8r/+JYm
XmStT1iGL9B+oLvJWXqB+nSfYI1/25/SRJldmPmk02cxyM4f4nyKMjCX+/Fyd0GPTOVkf6
fnzS9eC810HP5bmYEHgZYfJYQAqCMk0hkOIp5RH5jimu6Csv1uMrptE/7dkYgXzU+QJDp3
SbzmYddfaq+9fjwpFftyHXQSk+MtA7sMpD4n2+bAvAx5AAAAgQDkvvedNDP8OVvkRia/CT
x8hzqgjrlv18UV21zVU8maeoLlsjSuUD0f41VRbD5iz1zOGOiQQX05feLOVBdZtggqA+Mj
ZJdDM7r0r9fmPz9oRKEbM7VN8TNnvkS9idA7ptvvjnSC5KRyNAPwDVgd3HqC3d2UW1L1yL
00t5iRa3ewlQAAAIEA+f+XBI6iR470xytUIlM5jFFZxwH/xkAhNNSwhAONM4AkZ/5ImuJg
ZMxSASw2/Q6UCR1/Nsp32FAMtEOdmKMfKVlhFwJ2Y8C/qzN7OZ1P5IxaGBeiphDScCTG9i
otP+5bRnff3Lzfm1eIeiXkAvHGKlnGxmQx2woS2lnAldZi/NcAAACBANi7dN74LVS9m3av
Hc2Cs22JFdRv2MUjS1NJlF9t8QXoXolH2mUnEK6EfSDRHgmelZ4kkIMEHKwHpCfTKwJmci
B3yfpB4gdnS0QGr+BftpcjaMCv/5lzlmP86e8ucLAq87lSD9lK5Ux2IUxCOFpj7nxS8oc+
g60pv8yPkpbWyaFdAAAAJmdyYW50cG93ZWxsQEdyYW50cy1NYWNCb29rLVByby0yLmxvY2
FsAQIDBA==
-----END OPENSSH PRIVATE KEY-----

AGAIN, these are not keys I’m really using, they’re just for debugging why the BEAM won’t pick up the host key

Any insights would be appreciated

Marked As Solved

GrantJamesPowell

GrantJamesPowell

Update, the :ssh.daemon works with openssh ed25519 keys

mkdir ssh_dir
ssh-keygen -t ed25519 -f ssh_dir/ssh_host_ed25519_key
:ok = :ssh.start()
{:ok, sshd} = :ssh.daemon(8989, system_dir: 'ssh_dir', password: 'foo')
➜  erl_ssh_2 ssh 127.0.0.1 -p 8989
SSH server
Enter password for "grantpowell"
password:
Eshell V10.3.5.2  (abort with ^G)
1>

Where Next?

Popular in Questions Top

_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New

Other popular topics Top

TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41539 114
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31142 143
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New

We're in Beta

About us Mission Statement