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

dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
_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
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Codball
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
_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
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
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
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

We're in Beta

About us Mission Statement