# Using ser2net to remotely access a serial terminal or port

**URL:** <https://hub.mender.io/t/using-ser2net-to-remotely-access-a-serial-terminal-or-port/7807>\
**Category:** Tutorials\
**Tags:** linux\
**Created:** [June 2, 2025, 11:20am UTC](https://hub.mender.io/t/using-ser2net-to-remotely-access-a-serial-terminal-or-port/7807 "2025-06-02T11:20:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [June 2, 2025, 11:20am UTC](https://hub.mender.io/t/using-ser2net-to-remotely-access-a-serial-terminal-or-port/7807/1 "2025-06-02T11:20:24Z")

</div>

In this tutorial, we will guide you through the process of setting up and using `ser2net` to remotely access a serial terminal on a Linux computer. This setup is particularly useful for managing embedded systems, IoT devices, or any device that communicates over a serial interface.

## Prerequisites

- A Linux computer with a serial port (e.g., `/dev/ttyS0` or `/dev/ttyUSB0`).
- Basic knowledge of Linux command-line operations.
- We will assume a Ubuntu/Debian style system, instructions might need adaptation for other distributions.

## Installation

### Installing Ser2net

`ser2net` is a simple TCP-to-serial port redirector. To install `ser2net`, use the following command:

```bash
sudo apt-get install ser2net

```

## Getting started

`ser2net` uses a configuration file to define the mappings. This configuration file can hold a large number of exposed connections, but we will stick to the minimal case of one here.

### **Create a Configuration File**

Create the configuration file for `ser2net`. The expected location is `/etc/ser2net/ser2net.yaml`.

```bash
sudo nano /etc/ser2net/ser2net.yaml

```

### **Add Configuration Entries**

Add entries to the configuration file to define the mappings. For example:

```yaml
connection: &ttyUSB0
  accepter: tcp,2000
  options:
    banner: mybox - ttyUSB0
  connector: serialdev,/dev/ttyUSB0,115200n81,local

```

This entry maps TCP port `2000` to `/dev/ttyUSB0` with a baud rate of `115200`, 8 data bits, no parity, and 1 stop bit. The `banner` option displays a message when a connection is established.

### **Test `ser2net`**

Start the `ser2net` service:

```bash
sudo ser2net -d

```

This starts `ser2net` in non-detached mode, so you can see eventual error messages. This is particularly helpful when working on the configuration file.

From a remote machine, use `telnet` to connect to the exposed serial port:

```bash
telnet <linux_computer_ip or hostname> 2000

```

You should see the configured banner message and be able to interact with the serial port. `telnet` can be closed by entering command mode with `Ctrl-]` and then issueing `quit`.

### **Permanently enable `ser2net`**

Once you are done with setting the correct configuration up, you can have the `ser2net` service started automatically. Enable `ser2net` to start on boot:

```bash
sudo systemctl enable ser2net

```

And if you want to use it right away without rebooting, you can also start the service with:

```bash
sudo systemctl start ser2net

```

## Accessing the serial terminal remotely

From a remote machine, use a terminal emulator like `telnet` to connect to the Linux computer:

```bash
telnet <linux_computer_ip or hostname> 2000

```

Alternative tools are `nc` or `socat`, depending on the specific use case.

## Further Resources

- [Ser2net Documentation](https://github.com/cminyard/ser2net)

By following this tutorial, you should be able to set up and use `ser2net` to remotely access a serial terminal on a Linux computer. This setup provides a flexible and powerful way to manage serial communications over a network.
