Enabling a USB Serial Port Console: getty systemd | Linux & Open Source
- Source: https://www.rogerirwin.co.nz/linux-open-source/enabling-a-serial-port-console/
- Update by Phillips Hsieh
Using the serial port to login is a good way to get access to a device that doesn't have a network connection. This could be a small embedded Linux computer.
Raspberry Pi
enable_uart=1
# after reboot
systemctl enable serial-getty@ttyS0.service
systemctl start serial-getty@ttyS0.service
# Or
raspi-config
# select 3 Interface Options -
# I6 Serial Port
# Would you like a login shell to be accessible over serial? Yes
# Would you like the serial port hardware to be enabled? Yes
# Reboot
On a Raspberry Pi you can edit /boot/firmware/config.txt and add this at the bottom. Then reboot. More details can be found here.
Linux devices with systemd
# For a USB serial adaptor
systemctl enable serial-getty@ttyUSB0.service
vim /etc/systemd/system/getty.target.wants/serial-getty@ttyUSB0.service
# Modify like below that allow auto login root then ask password
# ExecStart=-/sbin/agetty -o '-p -- \\u' --keep-baud 115200,57600,38400,9600 --autologin root %I $TERM
systemctl daemon-reload
# For a built in serial port /dev/ttyS0
systemctl start serial-getty@ttyUSB0.service
You can now log in using the serial console on /dev/ttyUSB0 or /dev/ttyS0
- Connect another computer to it using a NULL modem cable.
- Then open a terminal emulator such as minicom which support send [send break F] trigger with CTRL-A (key)
- Set the baud rate and port.
- Press enter a few times and you should then see a login prompt.