nsweeting

nsweeting

Unable to connect to SFTP server in docker container

Hi there,

I’m having an issue with connecting to an SFTP server from within a docker container on a GCP instance. Its likely a configuration issue with the image , but was just wondering if someone had some insight. I can replicate the issue within a container locally as well - but it works when I just boot up the application outside a container.

These are just pretty standard erlang 22/elixir 1.9 alpine images.

The SFTP library is here: https://github.com/i22-digitalagentur/sftp_client

This is the stacktrace:

app_1       | 14:33:52.212 [info] Erlang SSH :client 4.8 (OpenSSL 1.1.1g  21 Apr 2020).
app_1       | Server: 'SSH-2.0-2.0'
app_1       | Disconnects with code = 11 [RFC4253 11.1]: Internal error
app_1       | State = {key_exchange,client,init}
app_1       | Module = ssh_connection_handler, Line = 1590.
app_1       | Details:
app_1       |   Reason: {badmatch,{error,eacces}}
app_1       | 
app_1       | 
app_1       | 14:33:52.217 [error] GenServer #PID<0.5079.0> terminating
app_1       | ** (Protocol.UndefinedError) protocol String.Chars not implemented for {{:badmatch, {:error, :eacces}}, [{:ssh_file, :default_user_dir, 1, [file: 'ssh_file.erl', line: 394]}, {:ssh_file, :file_name, 3, [file: 'ssh_file.erl', line: 222]}, {:ssh_file, :do_lookup_host_key, 4, [file: 'ssh_file.erl', line: 247]}, {:ssh_file, :is_host_key, 4, [file: 'ssh_file.erl', line: 91]}, {:ssh_transport, :known_host_key, 3, [file: 'ssh_transport.erl', line: 880]}, {:ssh_transport, :handle_kex_ecdh_reply, 2, [file: 'ssh_transport.erl', line: 698]}, {:ssh_connection_handler, :handle_event, 4, [file: 'ssh_connection_handler.erl', line: 711]}, {:gen_statem, :loop_state_callback, 11, [file: 'gen_statem.erl', line: 1161]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 249]}]} of type Tuple. This protocol is implemented for the following type(s): Decimal, NaiveDateTime, BitString, Atom, Version.Requirement, Version, URI, Date, Time, Float, List, Integer, DateTime
app_1       |     (elixir) lib/string/chars.ex:3: String.Chars.impl_for!/1
app_1       |     (elixir) lib/string/chars.ex:22: String.Chars.to_string/1
app_1       |     (sftp_client) lib/sftp_client/operation_util.ex:60: SFTPClient.OperationUtil.handle_error/1
app_1       |     (sftp_client) lib/sftp_client/operations/connect.ex:140: SFTPClient.Operations.Connect.do_connect/1
app_1       |     (sftp_client) lib/sftp_client/operations/connect.ex:49: SFTPClient.Operations.Connect.connect/1

Any help would be appreciated.

Thanks

Marked As Solved

entone

entone

I’m not familiar with that library, but I have gone down this path the erlang library that this wraps, we were using key files for auth, so I’m not exactly sure what this would be expecting if you are using a username and password.

However, checkout the options here, https://hexdocs.pm/sftp_client/SFTPClient.Operations.Connect.html#connect/1 you may need to at least pass in a path for :user_dir that contains a .ssh directory with the proper permissions. Could just throw an empty .ssh dir in the priv directory, and point to it with :code.priv_dir(MyAppName). Just be aware of the permissions needed for the .ssh directory. If I remember, Erlang was pretty specific.

Where Next?

Popular in Questions Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
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
logicmason
Hi there, I'm working through my first release with elixir/phoenix. I've built a release with distillery and found that it crashes when I...
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
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
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
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
Mooodi
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work. Or rather, not char, but a substr...
New

Other popular topics Top

chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
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
_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
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
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
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
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
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
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New

We're in Beta

About us Mission Statement