openssh icon indicating copy to clipboard operation
openssh copied to clipboard

test connect_timeout does not seem to work

Open stepga opened this issue 3 years ago • 11 comments

26 of the 27 test pass, excluding connect_timeout.

instead of resulting in a timeout, ssh seems to fail with: "connect to host 192.0.0.8 port 22: Network is unreachable"

when changing the test's host ip e.g. to the google dns 8.8.8.8 it works.

stepga avatar Feb 26 '22 00:02 stepga

Just run it again.

Sometimes timeout might fail, but it usually works.

NobodyXu avatar Feb 26 '22 00:02 NobodyXu

BTW, this is related to #41 , so I expected you to post this in the Pull Request

NobodyXu avatar Feb 26 '22 00:02 NobodyXu

@stepga If the problem is solved, can we close this issue?

NobodyXu avatar Feb 26 '22 01:02 NobodyXu

Just run it again. Sometimes timeout might fail, but it usually works.

Strange. It fails reproducibly every time I run run_ci_tests.sh

BTW, this is related to https://github.com/jonhoo/openssh-rs/pull/41 , so I expected you to post this in the Pull Request

This happens on origin/master 26e275654768519a0e3f676e5473d86b43228816. edit: fixed commit

stepga avatar Feb 26 '22 01:02 stepga

Strange. It fails reproducibly every time I run run_ci_tests.sh

That is definitely strange.

This happens on origin/master e1c02a749aba7352021b7a8b24ce15555271b1e2.

Can you try the latest commit of master?

NobodyXu avatar Feb 26 '22 01:02 NobodyXu

Strange. It fails reproducibly every time I run run_ci_tests.sh

That is definitely strange.

This happens on origin/master e1c02a7.

Can you try the latest commit of master?

i updated/edited the former post: this happens for me with https://github.com/jonhoo/openssh-rs/commit/26e275654768519a0e3f676e5473d86b43228816

stepga avatar Feb 26 '22 01:02 stepga

instead of resulting in a timeout, ssh seems to fail with: "connect to host 192.0.0.8 port 22: Network is unreachable"

when changing the test's host ip e.g. to the google dns 8.8.8.8 it works.

Looking at the error message, this actually matches the host used in connect_timeout.

The test basically specifies a random host and port, expects ssh connection to fail, it is not very robust.

Although I don't understand why changing the host ip fixed the problem.

NobodyXu avatar Feb 26 '22 01:02 NobodyXu

@jonhoo I don't think I can figure a solution to this one.

Can you please lend me some help here?

NobodyXu avatar Mar 01 '22 13:03 NobodyXu

Hmm, this sounds an awful lot like you have firewall rules that treat 192.0.0.8 specially. Or maybe that somehow matches your own local network? I think we need more info here, like your OS, the firewall you're using (if any), and your local network config (ip + netmask).

jonhoo avatar Mar 04 '22 17:03 jonhoo

I am seeing a similar issue when I try to ssh to an IP address that is only exposed when my VPN is on.

ssh will hang indefinitely if the ConnectTimeout is not set, but will finish if the ConnectTimeout is set.

ssh 172.16.1.2 -o ConnectTimeout=1
ssh: connect to host 172.16.1.2 port 22: Connection timed out

The example in my code appears to hang forever which indicates that the ConnectTimeout is not being passed correctly. The code works fine when my VPN is enabled.

let _sb = SessionBuilder::default()
        .connect_timeout(Duration::new(2, 0))
        .known_hosts_check(KnownHosts::Accept)
        .connect("172.16.1.2")
        .await;

jaystile avatar Apr 20 '23 00:04 jaystile

Now it is working for me. I didn't change anything, so I am confused. You can ignore my previous comment.

stilesj-uchicago avatar Apr 20 '23 01:04 stilesj-uchicago