ESP32_curl_example icon indicating copy to clipboard operation
ESP32_curl_example copied to clipboard

Cannot use SFTP function towards an OpenSSH server on Ubuntu

Open pantaluna opened this issue 6 years ago • 1 comments

Thanks for the library. The standard code works fine.

The plan is to use SFTP-SSH (with user and password credentials) to upload files to an Ubuntu server.

So I was testing the steps "#### SFTP DOWNLOAD TEXT FILE" and "#### SFTP UPLOAD JPG FILE" towards a local Ubuntu Server but it always return errors.

  • I only changed WIFI credentials, static char SFtp_pass[] static char SFtp_pass2[] static char SFtp_getfile_testURL[] SFtp_putfile_testURL[]
  • The "kex protocol error" in the sshd server log indicates a problem with the Key Exchange Algorithms (curve25519*, ecdh-sha2*, diffie-hellman-group*, ...).
  • The server works fine when accessed from a client such as FileZilla with the same credentials.
  • The mbedTLS debugging shows nothing at all but that is probably because libssh2 is used for SFTP/SSH.

Environment:

  • ESP32: Latest ESP-IDF.
  • ESP32_curl_example: master branch.
  • Ubuntu 17.04 openssh-server:amd64/zesty 1:7.4p1-10 uptodate

Make monitor log:

#### SFTP DOWNLOAD TEXT FILE
     Download small text file from SFTP (SSH) server
* timeout on name lookup is not supported
*   Trying 192.168.0.95...
* TCP_NODELAY set
* Connected to 192.168.0.95 (192.168.0.95) port 12700 (#0)
* Operation timed out after 20000 milliseconds with 0 out of 0 bytes received
.....waiting a long time.....
* Closing connection 0
curl_easy_perform failed: Timeout was reached
     ERROR: -7 [Timeout was reached]
.....................................................
#### SFTP UPLOAD JPG FILE
     Upload JPG file to SFTP (SSH) server
* timeout on name lookup is not supported
*   Trying 192.168.0.95...
* TCP_NODELAY set
* Connected to 192.168.0.95 (192.168.0.95) port 12700 (#0)
.....waiting a long time.....
* Operation timed out after 20000 milliseconds with 0 out of 0 bytes received
.....waiting a long time.....

The error in /var/log/auth.log is always like this:

Apr 17 21:26:21 xxx sshd[20955]: Connection from 192.168.0.192 port 64814 on 192.168.0.95 port 12700
Apr 17 21:26:21 xxx sshd[20955]: error: kex protocol error: type 30 seq 1 [preauth]

I also tried the scenario after modifying sshd_config by adding again some unsecure KEX's but it did not help: nano /etc/ssh/sshd_config

    ### Append @ end
    ###ESP32 project https://github.com/loboris/ESP32_curl_example
    KexAlgorithms=+diffie-hellman-group1-sha1
    KexAlgorithms=+diffie-hellman-group-exchange-sha1

Thanks for your time.

pantaluna avatar Apr 17 '18 20:04 pantaluna