1

I'm currently learning about terminals, pseudo-terminals, etc. and I'm curious - today we all use the pseudo-terminals such as xterm or gnome-terminal that are part of the Linux GUI, and less often the virtual consoles which are part of the kernel. In this area I pretty much know how things work, what happens when and what players are there. What if I want to log in to my Linux machine using an external device which will simulate the old TTYs (like the famous VT100). I can use another linux machine for this, or a Raspberry pi, Arduino, whatever.

For the manner of sake, I want to use a USB-to-serial converter.

How is this done?

YoavKlein
  • 332

2 Answers2

1

On the host side you need to run something which will listen on the serial port for a connection then hand off to /bin/login when a connection is negotiated. That something is typically a program named getty.

On the device where the screen and the keyboard are you need some sort of terminal emulator. Minicom has been the most popular choice on Linux for a number of years.

symcbean
  • 5,540
  • please take a look at https://unix.stackexchange.com/questions/22545/how-to-connect-to-a-serial-port-as-simple-as-using-ssh. Is it the same question? What does he/she mean by "How to connect to a serial terminal"? – YoavKlein Apr 20 '22 at 05:52
  • I don't know, that question is very ambiguous. A lot of the answers look a lot more complicated than minicom. But the content of the answers is relevant to your question. – symcbean Apr 20 '22 at 10:50
1

To allow incoming logins in a serial port/TTY device in modern distributions using systemd, you'll usually just need to enable a service named serial-getty@<device name>.service.

For example, to immediately start accepting incoming logins in serial port /dev/ttyS0:

systemctl start serial-getty@ttyS0.service

To allow incoming logins persistently on /dev/ttyS0, so that you don't need to re-enable it after a reboot:

systemctl enable serial-getty@ttyS0.service

The same should work for USB-to-serial converters, as long as the name of the TTY device name stays the same.

So if you have multiple USB-to-serial converters connected to the Linux system that is going to accept serial port logins, you might want to set up some udev rules to specify fixed names (aliases) for the /dev/ttyUSB* devices by converter serial number, USB device path or some other persistent unique identification, and start the serial-getty service instances using those aliases. But if all your USB-to-serial converters should be treated the same, this might not be necessary.

telcoM
  • 96,466