Ever wanted to use SSH to connect to an embedded Linux system over the serial port instead of suffering through some janky login program that supports very limited terminal features?

Well, I did, and the tooling didn't exist, so I made it.

It also supports ppp automatically.

cc @AMS @chaos

https://github.com/ryancdotorg/ugetty

GitHub - ryancdotorg/ugetty: A modern, lightweight, multi-protocol getty.

A modern, lightweight, multi-protocol getty. Contribute to ryancdotorg/ugetty development by creating an account on GitHub.

GitHub
@ryanc @AMS @chaos I'm probably missing something, but yeah working with serial TTY's feels more clumsy than it should. I tend to just use `screen`, but it is a weird program.
@pawv @ryanc i've found tio to be a wonderful and under-known program for doing serial stuff with more modern setups (i don't think this comes close to 'replacing' what OP made by any means though, layering SSH over it has some really compelling applications)

@pawv @ryanc @AMS @chaos also, GNU screen’s baudrate detection is indeed wonky.

If I know the baudrate, I tend to just run cu(1) in a normal screen tab. Has to get the size (80×24 usually) right, though…

@ryanc could this work for sftp as well?
@chaos Yes, it'll handle ssh/scp/port forwarding/rsync/git/etc.
@ryanc @AMS @chaos Awesome! this has always bothered me. now I only have to remember how to exit ssh

@ryanc @cinebox @AMS @chaos on a new line (perhaps press Enter+~+.).

If you’re already in an ssh connection, you need to escape it by doubling (tripling, …) the tilde.

@ryanc @AMS @chaos Fascinating, it's not something I'd ever have asked for, but thinking about it, it solves so many actual problems. It was one of those wonderful pieces that enable quite a lot of possibilities.
@ryanc oh delicious, i love this!
@ryanc @AMS @chaos huhhhhhhh. neat. if we did things that way we could use scp instead of our current workflow, which uses xmodem.
@ryanc @AMS @chaos (we don't trust our own LAN, so we have a workflow for bringing up new machines using the serial port)
@ireneista @ryanc "zero trust begins at home", interesting! i aspire to that ideal, sometimes.
@astrid @ryanc we figure if we don't learn how to do it ourselves, we can't teach anyone else to do it
@ireneista @ryanc @AMS @chaos huh, could one write a UEFI boot loader that uses serial comms to get the kernel/initrd, etc.

@ryanc @AMS @chaos oh!

That’s also useful to ssh into a libvirt console, isn’t it?

I’ll have to play with this.

@ryanc @AMS @chaos mind that there are current attempts to reduce the network size of 127/8 and AFAIHH FreeBSD already implements this.

execing sshd in inetd mode instead of connecting to a running one could also be interesting…

@mirabilos @AMS @chaos Yeah, I considered sshd -i, but that would have required environment manipulation. setenv() needs malloc, which ugetty doesn't otherwise use. Handling the identification string also requires reading it to detect it, then replaying it to sshd. This could be done by forking, replaying the string, then replacing the file descriptors (I think), but the socket method feels cleaner.

@ryanc @AMS @chaos ah, that is annoying, of course.

Can you MSG_PEEK on a serial port? Then you could indeed just exec.

@mirabilos @AMS @chaos I don't believe so, as a serial port is not a socket.
@ryanc @AMS @chaos might still have 15 bytes buffered or so…

@ryanc @AMS @chaos this is excellent, thank you!

I wanted to run ssh over Bluetooth Serial Port Profile (I have a JDY-31 dongle wired to the serial console of my device), and couldn’t figure out how to bodge it together. This looks like it should do the trick!

@RoganDawes @AMS @chaos Yup, should work. Though for something wireless, you may want to run SSH over PPP so that it doesn't die the first time a packet gets dropped.

@ryanc it should also watch for ESC-ESC and run a local BBS 🙂

@AMS @chaos

@ryanc @AMS @chaos oh, need to share this at work, though I doubt that we’ll use it it would be sweet since we do serial comms on a few types of systems and this looks cool.