← Back to list

How to Access a Remote Device Over the Internet (ser2net + socat)

Is it possible to access a hardware device connected to a remote computer over the internet?

Cengizhan Varlı · 2025-03-28 23:29 · 1 claps · 1.7 min read
#linux #tcp-ip #socat #remote-access #ubuntu
Open on Medium ↗
Wiki topics: 🔒 · Cybersecurity 🔓 · Open Source

How to Access a Remote Device Over the Internet (ser2net + socat)

Is it possible to access a hardware device connected to a remote computer over the internet?

Yes!

In this article, I will explain how to do this on Linux.

Our formula is ser2net + socat.

The remote PC to which the hardware is connected

Firstly, we need to install ser2net on the Linux computer where the hardware is connected. We can install it using the following command:

sudo apt update && sudo apt install ser2net

As you may know, configuration files are located in the /etc directory. Here, we need to find the file named ser2net.conf.

Note: In older versions, the configuration file is /etc/ser2net.conf. In newer versions, it may be located at /etc/ser2net/ser2net.yaml with a different syntax.

We need to open this file with a text editor (gedit, nano etc.) and add the service information for the hardware we want to use at the bottom of the file, for example, like below:

2001:raw:600:/dev/ttyUSB0:9600 8DATABITS NONE 1STOPBIT

Here:

2001 → The port number that will be used to access the device over the network

/dev/ttyUSB0 → Path of the serial device on the remote machine

9600 8N1 → Serial communication parameters (Baud rate: 9600, 8 data bits, No parity, 1 stop bit)

Save the changes you made and exit. Then, restart the Ser2Net service as shown below:

sudo systemctl restart ser2net

The other PC

If socat is not installed on your computer, you can install it using the following command:

sudo apt install socat

Then, we can create our socat connection as shown below:

socat -d -d pty,link=/dev/virtual-serial,raw tcp:REMOTE_PC_IP:2001

Here, you should be careful when entering the IP address and port. You need to use the port number that you specified in the ser2net.conf file on the remote PC.

If everything is successful, a virtual serial port named /dev/virtual-serial will be created and connected to the remote serial port.

That’s it! Now, you can communicate with the remote hardware device via /dev/virtual-serial as if it was connected locally.

Note: You may need additional permissions to access the /dev/virtual-serial device. Make sure your user is a member of the dialout group or use sudo when accessing the virtual serial port. You can add your user to the dialout group with the following command:

sudo usermod -aG dialout $USER

Common use cases: Connecting to industrial devices, microcontrollers, or embedded systems remotely without direct USB connection.


메타데이터
post_id
ed08f70debaf
slug
how-to-access-a-remote-device-over-the-internet-ser2net-socat-ed08f70debaf
url
https://medium.com/@cengizhanvarli/how-to-access-a-remote-device-over-the-internet-ser2net-socat-ed08f70debaf
canonical_url
https://medium.com/@cengizhanvarli/how-to-access-a-remote-device-over-the-internet-ser2net-socat-ed08f70debaf
author_url
https://medium.com/@cengizhanvarli
status
ok
fetched_at
2026-07-20 12:20:55