How to I setup a login prompt using the USB-USB Null Modem?

To allow you to login to a Linux machine over the USB-USB Null Modem a getty needs to be ran on the end you're trying to log into. In this guide I will be logging in from the B end "From" to the A end "Target".

These instructions should work on both CentOS 7 and Ubuntu 18.04.3 LTS

On both sides tail /var/log/messages (CentOS) or /var/log/kern.log (Ubuntu) and plugin the adaptor watching for the new devices entries which will look something like this.

kernel: usb 1-12: new full-speed USB device number 9 using xhci_hcd
kernel: usb 1-12: New USB device found, idVendor=3171, idProduct=0032, bcdDevice= 1.10
kernel: usb 1-12: New USB device strings: Mfr=1, Product=2, SerialNumber=3
kernel: usb 1-12: Product: USB-USB Null Modem A
kernel: usb 1-12: Manufacturer: 8086 Consultancy
kernel: usb 1-12: SerialNumber: 0123
kernel: cdc_acm 1-12:1.0: ttyACM0: USB ACM device

From the above log lines take note of what your machine uses in place of "1-12" and replace that in the examples below (for each side).

On the target machine create a new udev rule to rename the interface. Edit /etc/udev/rules.d/serial.rules and add a line similar to this.

# Serial Console Login:Target / Access:From
SUBSYSTEM=="tty", ATTRS{idVendor}=="3171", ATTRS{idProduct}=="0032", ATTRS{serial}=="0123", SYMLINK+="ttyFromTarget"

Replacing "Target" with the name of the machine you're logging into and From with the name of the machine you're logging in from.  Also replace the serial number "0123" above with the serial number of your device.

Now on the from machine create a new udev rule to rename the interface. Edit /etc/udev/rules.d/serial.rules and add a line similar to this.

# Serial Console Login:From / Access:Target
SUBSYSTEM=="tty", ATTRS{idVendor}=="3171", ATTRS{idProduct}=="0033", ATTRS{serial}=="5123", SYMLINK+="ttyFromTarget"

You will notice here both the serial number and product ID are different to what we added on the Target machine to allow ease of identifying each side of the USB-USB Null Modem.

Reload the udev rules on both machines.

udevadm control -R

If you're running ModemManager this can be stopped and disabled unless you also use Modems (CentOS).

service ModemManager stop
systemctl disable ModemManager

Unplug and replug the USB-USB Null Modem or run the following commands replacing the "1-12" with what you had in the log above (this will be different on both sides).

echo 0 > /sys/bus/usb/devices/1-12/authorized
echo 1 > /sys/bus/usb/devices/1-12/authorized

Now we can enable and star the getty (login prompt) on the Target machine.

systemctl enable serial-getty@ttyFromTarget
systemctl start serial-getty@ttyFromTarget

On the "From" machine you should now be able to connect to the serial device "screen /dev/ttyFromTarget 115200", press enter a couple of times and you should see a login prompt after a few moments.

You cannot comment on this entry