Linux - connect to a serial port with screen

CaffeineFueled

2022/12/09

There are a bunch of programs out there, that can get you connected to a serial port of a switch, but using screen was the best and easiest solution I’ve found. Works perfectly in the CLI, can be run in the background, and easy to set up - if it is not already installed.

It worked with various combinations of serial-to-usb-cables, Cisco switches, and Linux machines. Let us start with the command itself:

You can kill the session with CTRL + a, then k, and confirm it with y.

Finding the device / the tty number

Find the tty number while you are already connected:

sudo dmesg | grep tty

Output:

kuser@pleasejustwork:~$ sudo dmesg | grep tty
[    0.134050] printk: console [tty0] enabled
[1724834.635665] usb 3-1: FTDI USB Serial Device converter now attached to ttyUSB0

Shows the device while plugging it in:

sudo dmesg -wH | grep tty

Output:

kuser@pleasejustwork:~$ sudo dmesg -wH | grep tty
[sudo] password for kuser: 
[  +0,000022] printk: console [tty0] enabled
[  +0,001283] usb 3-1: FTDI USB Serial Device converter now attached to ttyUSB0

This is helpful if you are connected to multiple devices.

Finding the correct speed

I haven’t had to change this yet, but just in case:

sudo stty -F /dev/ttyUSB0

Output:

kuser@pleasejustwork:~$ sudo stty -F /dev/ttyUSB0
speed 9600 baud; line = 0;
-brkint -imaxbel



Most recent Articles:
  • Notice Board 003: Progress is Progress
  • How to: Cisco ISE backup to SFTP repository with public key authentication
  • Dummy IP & MAC Addresses for Documentation & Sanitization
  • Deploying ISSO Commenting System for Static Content using Docker
  • Generate a Vanity v3 Hidden Service Onion Address with mkp224o