ostap

ostap

`:ssh.daemon` - can't get port tunneling to work (via tcpip_tunnel_in: true)

Hello. I’ve noticed the tcpip_tunnel_in option in the Erlang documentation for the ssh module and trying to make it work.

defmodule MyApp.SSHDaemon do
  @sys_dir String.to_charlist("#{Path.expand(".")}/sys_dir")

  def start_link do
    :ssh.daemon(
      4445,
      system_dir: @sys_dir,
      no_auth_needed: true,
      # disconnectfun: &log_it/1,
      # connectfun: &log_it/3,
      # failfun: &log_it/3,
      tcpip_tunnel_in: true
    )
  end

  def child_spec(_) do
    %{
      id: __MODULE__,
      start: {__MODULE__, :start_link, []},
      name: __MODULE__
    }
  end

  def log_it(a1, a2 \\ nil, a3 \\ nil, a4 \\ nil, a5 \\ nil, a6 \\ nil) do
    require Logger

    Logger.debug(
      "#{inspect(a1)}, #{inspect(a2)}, #{inspect(a3)}, #{inspect(a4)}, #{inspect(a5)}, #{inspect(a6)}"
    )
  end
end

Here’s how I’ve generated the sample keys:

mkdir sys_dir
ssh-keygen -N '' -b 256 -t ecdsa -f sys_dir/ssh_host_ecdsa_key

Connecting to it this way:

❯❯❯ ssh -R 8082:localhost:8080 127.0.0.1 -p 4445
Warning: remote port forwarding failed for listen port 8082
Eshell V14.1.1 (press Ctrl+G to abort, type help(). for help)
1> 

Any advice or examples on getting TCP port forwarding to work here?

Marked As Solved

ostap

ostap

Turns out I misunderstood the options and the correct one is tcpip_tunnel_out, not tcpip_tunnel_in. (notice -R in my ssh command usage)

Where Next?

Popular in Questions Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
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
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
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
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
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
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
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
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
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
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
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement