Subject: Debugging SCP failure: "Timed out waiting for SCP response"

Debugging SCP failure: "Timed out waiting for SCP response"

From: Tim Martin <>
Date: Mon, 11 Oct 2010 09:51:18 +0200 (CAT)


I am trying to transfer a file from an SSH server using libssh2. The SSH server in question is running under RouterOS ( and seems to be misbehaving, but I don't know enough to narrow the problem down further.

The client can connect to the server and authenticate OK. I can also execute commands on the remote shell OK. However, when I try and call libssh2_scp_recv() I always get a null result. After the failure, libssh2_session_lasterror returns an empty string, and libssh2_session_lasterrno returns zero.

Test code and debug logs are available here:

The most noticeable log line is

[libssh2] 1.001111 Failure Event: -28 - Timed out waiting for SCP response

I believe on one occasion I got this error message returned by libssh2_session_lasterror() but I can't reproduce that. I don't know what the timeout should be, but it certainly isn't waiting very long before timing out (a fraction of a second at most).

I'd be grateful for any pointers as to how to proceed with this. I don't mind dipping into the libssh2 code, but I don't have the time to grok it at the moment. I'm fairly sure the problem ultimately lies on the RouterOS side, but I don't want to give up if there's a simple workaround.

Received on 2010-10-11