Search code examples
at-commandesp8266

sftp connection over esp8266 module


I am trying to make a sftp connection using esp8266 wifi module but I am facing problems. First I successfully connected esp8266 to my router then I tried making tcp connection to sftp server by using following command

AT+CIPSTART="TCP","[email protected]",22

but I always get "DNS FAIL" reply from esp8266. How can I make a sftp connection using esp8266 wifi module?


Solution

  • According to https://github.com/espressif/ESP8266_AT/wiki/CIPSTART the syntax of the AT+CIPSTART command is

    AT+CIPSTART=type,addr,port 
    

    Your "address" parameter must be just the hostname. It seems you're putting a URL there with a username ([email protected]). The hostname should just be test.rebex.net, right? The literal hostname [email protected] does not exist and can therefore not be DNS-resolved, which explains the error. The authentication as the user demo is handled in the protocol run then.

    Note however that SFTP is a complex protocol. That CIPSTART command just opens a raw TCP socket to that hostname and that port for you. Specifically, issuing that command does not execute any high-level protocol logic for you. It's just a socket that you can write and read to. If you mean by SFTP FTP over SSL you need to be able to make a SSL protocol run with all the cryptography involved. If by SFTP you mean Secure File Transfer Protocol (SFTP) you need an SSH implementation (and rather similar cryptographic primitives). These sort of computations are definitely not suitable for an Arduino which just sends AT+ commands, so I would suggest programming the ESP8266 directly. The esp-open-rtos has plenty examples for doing SSL connections, but SSH or SFTP is not implemented yet.