SSH Client

gregstewart90
Posts: 59
Joined: Thu Jan 19, 2017 5:17 pm

SSH Client

Postby gregstewart90 » Wed Mar 08, 2017 12:51 am

I have have a wireless range extender that I would like to configure with the ESP32. I can ssh into the range extender and update configuration files. Is there anyway to ssh into a linux box from the ESP32?

The idea is that I can have the ESP32 look for the default SSID of the range extender. Once it finds it, it can connect and update the configuration files. This way I do not have to manually update the configuration files of the range extender or use the web ui of the range extender.

Thoughts?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: SSH Client

Postby WiFive » Wed Mar 08, 2017 3:08 am

Not sure what the advantage of using the esp32 for this is over a script on an android phone or something.

ESP_Sprite
Posts: 9772
Joined: Thu Nov 26, 2015 4:08 am

Re: SSH Client

Postby ESP_Sprite » Wed Mar 08, 2017 4:22 am

We do not have anything out of the box, but maybe you can give porting LibSSH or LibSSH2 a try?

spiramirabilis
Posts: 1
Joined: Thu Mar 09, 2017 8:24 am

Re: SSH Client

Postby spiramirabilis » Thu Mar 09, 2017 9:07 am

Does the extender support TLS over telnet? Thats probably a lot easier to get working quickly.

gregstewart90
Posts: 59
Joined: Thu Jan 19, 2017 5:17 pm

Re: SSH Client

Postby gregstewart90 » Fri Mar 10, 2017 2:59 pm

They do support telnet, but I am not sure about TLS over telnet. I'll have to confirm. If so, should I use a library like this one?
https://github.com/seanmiddleditch/libtelnet

How exactly do I get the LibSSH or LibSSH2 library to work on the ESP32? Or any external library for that matter? I use eclipse and code in c.

preetam
Posts: 49
Joined: Thu Jan 26, 2017 2:31 pm
Location: Germany

Re: SSH Client

Postby preetam » Fri Mar 10, 2017 3:03 pm

This might help you viewtopic.php?t=815

gregstewart90
Posts: 59
Joined: Thu Jan 19, 2017 5:17 pm

Re: SSH Client

Postby gregstewart90 » Tue Mar 14, 2017 7:14 pm

I followed the example you gave, and it worked for the mongoose. When I tried to do the same for libssh, I ran into issues.

I created a directory in my project directory called components, cloned libssh into the components directory, added the file component.mk, and included the library in my project main.c.

Code: Select all

mkdir components
cd components
git clone git://git.libssh.org/projects/libssh.git libssh
cd libssh
nano component.mk //File contains one line: COMPONENT_ADD_INCLUDEDIRS=.
When I include the <libssh/libssh.h> library, the compiler says No such file or directory.

Inside the libssh directory I cloned, I found an include directory. I changed my #include <libssh/libssh.h> to #include <include/libssh/libssh.h>. Now the compiler says:

Code: Select all

fatal error: sys/select.h: No such file or directory
Any ideas? Do I need to build libssh first? If so, how do I build it for the esp32 and include it?

Thanks

gregstewart90
Posts: 59
Joined: Thu Jan 19, 2017 5:17 pm

Re: SSH Client

Postby gregstewart90 » Thu Jun 08, 2017 5:39 pm

This post uses libssh2. It works for needs

J-Rios
Posts: 1
Joined: Sun Jul 21, 2019 8:32 am

Re: SSH Client

Postby J-Rios » Sun Jul 21, 2019 8:49 am

Here is an Arduino library that implements an SSH client using libssh2:

https://github.com/J-Rios/Arduino-esp32sshclient


It also can be used from ESPIDF Framework too.

phando
Posts: 24
Joined: Wed Dec 14, 2016 5:30 am

Re: SSH Client

Postby phando » Wed Sep 18, 2019 4:35 am

I am looking to have an ESP32(client) establish an SHH session and send commands to another system.
When using the lib above and running any of the examples, my ESP32s keep failing to connect in the lets_handshake function.

Code: Select all

int8_t ESP32SSHCLIENT::lets_handshake(void)
I figure it is because the initial connection needs to establish authenticity of the connection. The lines below are what's in the terminal when trying to connect to my SSH server manually.

Code: Select all

The authenticity of host '192.168.1.25 (192.168.1.25)' can't be established.
ECDSA key fingerprint is SHA256:sgeYqimuwjN1Jp/bKelxHjbQKPUIGCt0UYjmSCcmwoo.
Are you sure you want to continue connecting (yes/no)?
Can I introduce a known hosts in the SPIFFS?
Is there a way to say yes to the the initial handshake?
Do any of you have a working example on an ESP?
Do any of you have an example using the longer connect command? I am unsure of the syntax for that connect call.

Code: Select all

 int8_t connect(const char* host, const uint16_t port, const char* user, uint8_t* pubkey, 
 	size_t pubkeylen, uint8_t* privkey, size_t privkeylen, const char* key_passphrase);
Thanks!

Who is online

Users browsing this forum: Baidu [Spider] and 75 guests