ewpa / LibSSH-ESP32

Libssh SSH client & server port to ESP32 Arduino library
https://www.ewan.cc/node/157
Other
257 stars 36 forks source link

Which comands i should use? #19

Open AposazhennikovDS opened 2 years ago

AposazhennikovDS commented 2 years ago

Greetengs sir! Thank you for your work! Im trieng to make SSH client on ESP32, my point is to connect my esp to server on linux and exec some comands on linux server. But then im trieng to use some default commands i get some errors, please could you give me link to actual documentation?`` ![scr](https://user-images.githubusercontent.com/101997038/172701784-4c9bde62-8eea-440f-b352-e4cba844ab5e.JPG)

ewpa commented 2 years ago

Hello, I'm missing the first error in your compilation which may hint to the issue. Have you compiled and run the examples successfully?

AposazhennikovDS commented 2 years ago

Thank you for your quick response, im just trying to make simply clien, and the examples are too complicated for me to understand, so, when i simply replaced "Your ssid"/ "localhost" and other vars to my vars it doesnt compilated because of error. I tried to use examples which named "exec" and OTAclientSCP(exec doesnt work; Otaclient is working). it would be great if i can wrote code by myself. So maybe you will help me to understand why in my code i gettings error like that ": error: 'SSH_OPTIONS_HOST' was not declared in this scope ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, ****)"

ewpa commented 2 years ago

Yes, the examples were ported mainly from upstream where they were written for Unix/Linux type systems. Hence for SSH_OPTIONS_HOST you may need to include additional headers, for example in exec.ino:

#include "libssh/priv.h"
#include <libssh/libssh.h>
#include "examples_common.h"
AposazhennikovDS commented 2 years ago

Thank you sir! I also have some questions about the algorithm of executing commands at the server. Am I to understand that firstly I must create two necessary objects "channel" and "session" if i want to send the commands? Also when i oppened channel can i send 2 or more(unlimited) commands to server? Or we have limit?

ewpa commented 2 years ago

Create a session first (connect_ssh). Then create a new channel in the session (ssh_channel_new). Next open a host session over that channel (ssh_channel_open_session). Execute something on the host (ssh_channel_request_exec). Start with something simple. The docs can be found upstream at https://api.libssh.org/stable/libssh_tutor_command.html