nsweeting

nsweeting

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: GitHub - tlux/sftp_client: An Elixir SFTP Client that wraps Erlang's ssh and ssh_sftp. · GitHub

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

Showing Posts 1 to 4

entone

entone

It looks like your creds aren’t available in the docker container. It’s looking in the default user directory, which probably works fine locally.

Depending on how you store your secrets for prod, and what your deployment system is, you will ptobably need to mount a directory in your container and pass the directory to the sftp client.

nsweeting

nsweeting OP

Thanks for the response @entone

Perhaps I don’t have enough knowledge of SFTP… but in this case, I just have a host, user and password for the SFTP server. These are accessed elsewhere and I know they exist in proper format. These are what I am passing to SFTPClient.connect/1.

From the error - it looks like its :ssh_connection_handler is trying to access ssh related files. I’m just not sure what setup is required within the dockerfile to satisfy the :ssh_file calls.

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, SFTPClient.Operations.Connect — SFTP Client v2.1.0 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.

nsweeting

nsweeting OP

Thanks @entone - this ended up being the solution. There were access issues for the default ssh folder within the container. Setting the :user_dir within the connect opts to a valid path worked.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews