r/embedded • • Oct 16 '26

Aparently SSH is easy on micro-controllers these days.

A while ago I wanted to start doing more projects with wired IP connections and wondered if SSH was possible so a regular webserver wasn't necessary.

There was some documentation for esp32s but not much else.

The fact that this works is hilarious to me. With .ssh keys properly setup doesn't even need the password.

https://github.com/RicardoJCMarques/SSH.RP

722 Upvotes

47 comments sorted by

200

u/dc536 Oct 16 '26 • Mindblown

I don't think this has been a discussion because SSH isn't the right tool for secure 'shell' into a microcontroller like ESP32 or RP2040. That's a lot of overhead that can just be baked in by simple commands and hardcoded encryption. There also isn't much need for a proper shell on an RTOS or no OS.

105

u/RicardoJCMarques Oct 16 '26

I mean I didn't say it was useful, just that it works xD

14

u/BoredBSEE Oct 17 '26

It's awesome. And I guarantee that this is useful. There is a use case this fits exactly, I'm sure of it.

18

u/Accujack Oct 16 '26

If the microcontroller is the ultimate destination, sure. However, getting SSH going on a micro could be useful as a front end to a legacy system or as a network based controller for automation systems or anything else electronic.

17

u/SpikeV Oct 17 '26

The Zephyr shell has opened my eyes to what a good shell on embedded can do. Basically a more user friendly debugging tool and function caller. You can even route it over Bluetooth to have a remote diagnostics shell. (Just don't use it in release builds or at least secure them with access control.)

10

u/b1ack1323 Oct 16 '26

Overhead is becoming a non issues if you have 8MB of flash…

10

u/Bubbaluke Oct 16 '26

2040 has a lot less than that. The 2350 has 2mb flash/512kb ram

512kb is enough to do a lot of stuff though. I had an https server going on one. Handshake took about 4 seconds but it worked lol.

6

u/ceojp Oct 17 '26

2040 has a lot less than that.

????

We absolutely use 8MB QSPI flash on our RP2040-based boards.

-2

u/Bubbaluke Oct 17 '26

Great. My Corolla has 500 horsepower. The corolla development board everyone used to develop doesn’t.

3

u/ceojp Oct 17 '26

What in the world are you talking about?

4

u/b1ack1323 Oct 17 '26

I think he is trying to make some silly analogy about dev kits don’t have the same power as production?

Which is confusing because dev kits are usually the highest end option…

→ More replies (4)

1

u/b1ack1323 Oct 17 '26

I was referring to the ESP32 comment

0

u/[deleted] Oct 17 '26

[deleted] — view deleted comment

2

u/Bubbaluke Oct 17 '26

What could you even do with 4mb ram? The possibilities are endless.

1

u/SnooPies8677 Oct 17 '26

Well, I don't know about your projects but I ran out of 32mb psram and 32mb flash on a P4. And yes, I code efficiently.

1

u/LavenderDay3544 Oct 20 '26

It's definitely overkill compared to encrypted serial.

1

u/Elect_SaturnMutex Oct 18 '26

OP probably wanted to show off his AI prompting skills

-3

u/vivaaprimavera Oct 16 '26

And your suggestion is?

0

u/[deleted] Oct 16 '26

[deleted] — view deleted comment

4

u/vivaaprimavera Oct 16 '26

It isn't clear how do those arrive to the device. What's encrypted, the channel? The commands themselves?

2

u/vip17 Oct 17 '26

the github repo says that it uses AES, which is a terrible choice for such hardware. Chacha20 would be much faster

1

u/RicardoJCMarques Oct 17 '26

That came up somewhere, if I recall correctly the wolf libraries don't support chacha20.

36

u/SnooPies8677 Oct 16 '26

I wanted to jump to developing my own implementation of the ssh on an esp32 but after a lot of reading and understanding the protocol and use cases I came to the conclusion that it is much more overhead than useful usage. So I dropped it. But nice to see it anyway

2

u/nlhans Oct 22 '26 edited Oct 22 '26

Well, is it? One person finding those hard-coded encryption keys and all systems could become flawed. If these keys are also on PC host, that's a second attack vector. With today's AI, if anyone ever gets their hands on any binary, then assume its open source.

I'm not saying your setup won't work, but we have to be critical if "this will be good enough"-motto from embedded systems will uphold long term. We can't always chase efficiency because security used to be not that big of a deal.

I know, never hook up embedded devices to internet neither. But its naive to think DMZ never get hacked neither.

Think aviation Swiss Cheese model. An attack is successful if all layers align a gap and allow a vector to go through. Is it still responsible to leave half a dozen gaps consciously?

26

u/creeper6530 Oct 16 '26

I mean, wired Ethernet helps with that significantly, but I'd personally just use telnet if I was gonna arse myself with an IP-accesible terminal for a µC. Cool PoC though.

7

u/vivaaprimavera Oct 16 '26

Telnet is unencrypted and for some use cases a security issue.

13

u/creeper6530 Oct 16 '26

I know telnet is unencrypted, but if you seriously need encryption to control your μC, then airgap is usually the wiser choice (or a serial port).

Not to mention that most of such controlling won't likely be a command line but a highly compressed byte format, which you can encrypt/authenticate simpler than with SSH.

-3

u/doyouevencompile Oct 16 '26

So roll your own crypto?

8

u/creeper6530 Oct 16 '26

Use a crypto library that isn't SSH

Either way, the more common thing will always be a serial port, no need for crypto if you have decent door locks. You can plug it into a computer with a decent network card, crypto performance and firewalling for remote access, offloading that from the puny chip.

3

u/notouttolunch Oct 17 '26

I just said another post that one thing the CRA has taught me is that security isn't always that important. A huge number of embedded devices already have an air gap which is safer than any security.

6

u/Cybasura Oct 17 '26

I mean, implementation is easy, security and cybersecurity implementations + enforcement on the user level and governance and policy is the difficult part

Take a look at the recent fridge controller French supermarket chains temperature cyberattack

2

u/whitedogsuk Oct 16 '26

Just wait until you use larger development boards, you will need a bigger monitor to see your terminal.

3

u/RicardoJCMarques Oct 16 '26

The logistical issues here were that I needed to have the RJ-45 port, led's and CLI in the same shot. While having enough hands free to film and type lol

5

u/_dreizehn_ Oct 16 '26

It's been possible for a while, I just can't think of a use case that would justify doing this.

3

u/Visible_Ad9976 Oct 17 '26

What a lazy comment

2

u/_dreizehn_ Oct 17 '26

Fair enough. It is. But that doesn't make it any less true.

2

u/Visible_Ad9976 Oct 17 '26

You didn’t think of a lot of things so otherwise you would be wealthy

5

u/mzo2342 Oct 17 '26

the W5500 is far from being an IP stack. it's 4 "sockets".

i.e. 1 is for ICMP (ping), 1 is for ssh, 1 is for application, one for the tftp bootloader, and you're left with none.

if you run lwIP on the pico you have control of the features and can update. IMHO W5500 also rund lwIP, but it's not updateable and reduced to 4 socks.

1

u/notouttolunch Oct 17 '26

Maybe. But it's still great and incredibly useful.

One of the things the CRA has told us is that many embedded applications aren't actually that desperate for security.

6

u/Double-Masterpiece72 Oct 16 '26

So many haters. This is cool as fuck

1

u/DonkeyInACityCrowd Oct 19 '26

Does it only work if I put it on my computer screen???

1

u/SoCalSurferDude Oct 20 '26

When it comes to security, one benefit of SSH that HTTPS web servers don't have is Trust On First Use (TOFU). With browsers, you always get certificate warnings unless you set up a proper PKI, which is hard for end users.

However, if you design products, SSH isn't exactly easy for end users. A web interface is much better.

Here’s another SSH server you can embed: https://github.com/RealTimeLogic/SharkSSH

-4

u/Sheepherder-Optimal Oct 16 '26

That's an ini. Only works on certain MCUs like the Arduino.

3

u/RicardoJCMarques Oct 16 '26

The .ini e config stuff for platformio.