Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Which comands i should use? #19

Open
ghost opened this issue Jun 8, 2022 · 5 comments
Open

Which comands i should use? #19

ghost opened this issue Jun 8, 2022 · 5 comments
Labels
question Further information is requested

Comments

@ghost
Copy link

ghost commented Jun 8, 2022

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
Copy link
Owner

ewpa commented Jun 8, 2022

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

@ewpa ewpa added the question Further information is requested label Jun 8, 2022
@ghost
Copy link
Author

ghost commented Jun 9, 2022

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
Copy link
Owner

ewpa commented Jun 9, 2022

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"

@ghost
Copy link
Author

ghost commented Jun 9, 2022

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
Copy link
Owner

ewpa commented Jun 9, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant