I have a device under test (DUT) and I measure its power usage the using a Power Analyzer Datalogger using the data from /dev/ttyUSB0.

The problem is that the DUT is now remotely from the workstation I used to gather data with, but in the same network, I need to use a 2nd PC which is directly connected via USB to the Power Analyzer as a sort of USB proxy and ssh to create a kind of symbolic link on the measuring machine of the USB of the "proxy" machine.

enter image description here

Given the above diagram how can the 1st PC access /dev/ttyUSB0 of the 2nd PC which is directly connected, in a way that a program reading the stream from the 1st PC will not notice the difference?

3 Answers 3


socat might work here.

On the 2nd PC you could let socat listen for data on /dev/ttyUSB0 and serve it to a tcp port, e.g:

socat /dev/ttyUSB0,raw,echo=0 tcp-listen:8888,reuseaddr

Then on 1st PC you can connect to 2nd PC with socat and provide the data on a pseudo terminal /dev/ttyVUSB0 for your application:

socat PTY,raw,echo=0,link=/dev/ttyVUSB0 tcp:<ip_of_pc2>:8888

This isn't tested and socat supports many options, so tweaking may be needed.

  • 5
    Thanks! Test environment in docker container on laptop -> SSH tunnel -> PC in clean-room -> AVR programmer and FTDI logger in clean-room Commented Feb 9, 2016 at 11:03

You can use a combination of ser2net and socat. For example, I have a robot connected to a raspberry pi through a serial port. The raspberry pi is connected to my local network (equivalent to your 2nd PC). And my laptop is connected to the same local network (equivalent to your 1st PC). Then I use ser2net to forward the serial port via TCP from the 2nd PC, and create a proxy serial device file using socat on the 1st PC.

This setup may work for you as well. Proposed solution:

Step 1: Install ser2net package on your 2nd PC (following your diagram)

sudo apt-get install ser2net

ser2net listens to a TCP port and is able to pipe data to and from a serial port via the TCP port. You can set up which serial ports you want to create "proxies" for via its configuration file /etc/ser2net.conf.

Step 2: configure ser2net in the 2nd PC

For example, if you have a device connected at /dev/ttyACM0 with baudrate 115200 and want to serve it from localhost port 3333, then you can add the following line to /etc/ser2net.conf


Having created the configuration file, then either start ser2net by running on the second PC:


or (if it's already running, then just restart it as below)

/etc/init.d/ser2net restart

One important thing here is the remctl option. It allows the client side (1st PC in your diagram) to connect to the device and choose the serial connection options freely. I think this way the serial communication is completely transparent from the data collection workspace perspective. See more details here.

Step 3: Set up proxy serial device file on the data collection workstation (1st PC)

(if you don't have socat, then sudo apt-get install socat)

Finally, in a terminal on the 1st PC let socat create a proxy serial port that will listen from the tcp port:

socat pty,link=$HOME/MyProxySerialPort,waitslave tcp:$ip:$port,forever,reuseaddr,keepalive

Where, in this example ip=<2nd-PC-IP-address> and port=3333 (or whatever you chose when setting up /etc/ser2net.conf on the 2nd PC).

Step 4: Connect to MyProxySerialPort

Now you should be able to open a serial connection normally to the device located at $HOME/MyProxySerialPort on the 1st PC.

This blog post has some more information about this setup too: http://techtinkering.com/2013/04/02/connecting-to-a-remote-serial-port-over-tcpip/


In linux kernels which are using a symbolic link from /dev/bus/usb/BUS_ID/DEV_ID to /dev/char/MAJOR:MINOR socat cannot open such devices due to an inappropriate IOCTL error!
So this approach does not seem to work directly on USB devices.

I tried usbip which is a closer implementation but only supported on older kernels.

Since my solution was about card readers connected via pcsc-lite there was a better solution using the environment variable for libpcsclite clients.

export PCSCLITE_CSOCK_NAME=$HOME/.pcscd.comm

This way a diferent unix domain socket can be specified. And this one can be forwarded to the card reader socket on a remote host using socat:

Run this on the host to replace the card reader


run this on the CARD_READER_HOST host with the pcsc card reader connected

socat UNIX-CONNECT:/var/run/pcscd/pcscd.comm tcp-listen:8888,fork,reuseaddr
  • 1
    Hi and welcome :). This is interesting information but it does not relate to the question about /dev/ttyUSB0, or a power analyzer which does not use PCSCLITE. If you would like to post this information, it would be better as a separate question. You are permitted and encouraged to post on-topic questions for which you have an immediate follow-on answer.
    – sourcejedi
    Commented Jul 19, 2017 at 18:18
  • 3
    I tried it and the relevant information was that the proposed answer DID NOT work! I think this info requires sharing. The rest is truly not directly relevant but offers a different approach for related problems.
    – U.V.
    Commented Jul 20, 2017 at 9:25
  • Would this be because of the : character in the path? The socat man page, section "ADDRESS SPECIFICATIONS", has a paragraph about how to escape characters (v1.5.0 onwards). Commented Nov 23, 2019 at 18:06
  • interesting point, but the project has been canned so no way to check it anymore :(
    – U.V.
    Commented Jan 27, 2020 at 18:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .