How can I log in to Ubuntu using a USB serial port?

9,428

Solution 1

See the Ubuntu Serial Console HowTo. You'll need to adapt it for your hardware -- instead of ttyS0, which is the first hardware serial port, you'll need to use ttyUSB0. An example of this is below.


At minimum, you need to configure upstart to start a getty on that port.

  1. Create /etc/init/ttyUSB0.conf and paste the following into it:

    # ttyUSB0 - getty on USB serial port
    #
    # This service maintains a getty on ttyUSB0 from the point the system is
    # started until it is shut down again.
    
    start on stopped rc RUNLEVEL=[2345]
    stop on runlevel [!2345]
    
    respawn
    exec /sbin/getty -L 115200 ttyUSB0 vt102
    
  2. Start the getty:

    sudo start ttyUSB0
    

Older Ubuntu versions and distributions that don't use upstart do this by adding a line in /etc/inittab.

This doesn't consider changes to the bootloader configuration to allow Grub to talk to the serial port; refer to the HowTo for details. I'm not sure if Grub can talk to a USB serial port or if that's limited to hardware ports.

Solution 2

Note that the above answers may work if your distribution is still using upstart as the init daemon. This is relatively rare these days however. For most modern systems using systemd as the init system, you can easily spawn a login prompt over a USB serial port as follows:

sudo systemctl start [email protected]

(Adjust @ttyUSB0 to whatever port you are using ttyS0, ttyUSB1, etc)

Then double check baud-rate etc using stty -F /dev/ttyUSB0 before logging in using your preferred serial terminal client.

Share:
9,428
Peter Mortensen
Author by

Peter Mortensen

Updated on September 17, 2022

Comments

  • Peter Mortensen
    Peter Mortensen over 1 year

    How can I enable remote terminal log in into Ubuntu 9.10 (Karmic Koala) using a USB serial port?

    I created device /dev/ttyUSB0, and I want to allow logins using HyperTerminal.

    I found some resources, but they are related to real hardware RS-232 ports. I can't find any information about a USB converter.

    So far I have established connection between that USB-serial port and my laptop. I can send text to the port (cp sometext.txt /dev/ttyUSB0) and read it using HyperTerminal.

    What do I need to do to enable logins on this port?

  • Peter Mortensen
    Peter Mortensen about 6 years
    Where should this go? Typed into a terminal window? In some Bash script?
  • Peter Mortensen
    Peter Mortensen about 6 years
    In file /etc/init/ttyUSB0.conf?
  • Like
    Like about 6 years
    Yes, /etc/init/ttyUSB0.conf