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

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
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
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
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
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
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 55125 245
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New

We're in Beta

About us Mission Statement