Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Cannot read anything from device? #27

Open
gazzer82 opened this issue Jun 29, 2023 · 1 comment
Open

Cannot read anything from device? #27

gazzer82 opened this issue Jun 29, 2023 · 1 comment

Comments

@gazzer82
Copy link

I am attempting to read some data from a network switch over ssh.

I can connect fine, but I always get a timeout waiting for data to be returned:

defmodule FibreTestUi.Ssh do
  defp connect do
    SSHEx.connect(
      ip: '192.168.1.1',
      user: 'admin',
      password: '!Password',
      modify_algorithms: [
        {:append, [{:kex, [:"diffie-hellman-group-exchange-sha1"]}]},
        {:append, [{:public_key, [:"ssh-rsa", :"ssh-dss"]}]}
      ]
    )
  end

  def list_port_status do
    {:ok, conn} = connect()
    SSHEx.cmd!(conn, 'show interfaces transceiver')
  end
end

When I call this I always get:

** (RuntimeError) {:error, "Timeout. Did not receive data for 5000ms."}
    (sshex 2.2.1) lib/sshex.ex:100: SSHEx.cmd!/3
    iex:1: (file)

If I manually SSH into the switch and enter the same command, then press enter/return I get a long stream of data back.

I've tried adding /r to the command, and increasing the exec_timeout (thought when testing I get the response in circa 1 second) with no change.

Any idea what I'm doing wrong here? Help greatly appreciated!

@moomerman
Copy link

moomerman commented Sep 9, 2024

In case anyone lands here in future, you can pass the :exec_timeout opt to theSSH.cmd! function, using the example above you would do:

SSHEx.cmd!(conn, 'show interfaces transceiver', exec_timeout: 60_000)

for a 60s timeout.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants