1

I'm trying to access a remote serial console (a tty port on a remote machine) as if it's on a local machine. This is necessary for a serial-port only application to work on my machine. The remote tty is not directly accessible. It is behind an OpenGear and I can connect to the actual tty only with telnet. If necessary I could drop the OpenGear just to confirm that things work without it in the middle.

I want to tell my application to use a local device like /tmp/my_virtual_tty and connect to the OpenGear telnet port transparently.

What works:

$ telnet remote_telnet remote_port

$ socat TCP:remote_telnet:remote_port TCP-LISTEN:10023
$ telnet localhost 10023

What doesn't work (nothing seems to get exchanged) but I wish it would:

$ socat tcp-connect:remote_telnet:remote_port PTY,link=$HOME/dev/vmodem0
$ screen $HOME/dev/vmodem0

The same thing with remserial:

$ remserial -d -r remote_telnet -p remote_port -l $HOME/dev/vmodem0 /dev/ptmx
$ screen $HOME/dev/vmodem0 .... # doesn't work either

This doesn't work either but since I did not specify any tty speed anywhere it might make sense:

$ screen $HOME/dev/vmodem0 115200

I tried raw/rawer options with socat and played with raw options of OpenGear without success. My questions are: what am I not seeing and what is the actual solution for remote serial port forwarding/tunneling?

crististm
  • 141
  • 1
  • 5
  • I think there's selinux issue. `socat` and `screen` are needed root privileges. Don't use home directory for devices. Create devices in `/dev` directory and you will not have any problems with selinux. – Mikhail Khirgiy Mar 28 '17 at 05:39
  • Selinux is disabled since I need all the freedom I can get on my work machine. The home file is just a symlink to /dev/pts/ and it's not at the root of the problem either. – crististm Mar 29 '17 at 08:53

2 Answers2

1

This will work seamlessly but only with a raw server (on the Opengear) and not with a telnet one:

$ socat -d TCP:server:port PTY,link=$HOME/dev/vmodem0,rawer,b115200,sane
$ screen ~/dev/vmodem0

That's it. Remserial will work exactly the same way so there is no need for a proprietary driver unless you are on Windows and probably not even then.

In fact, OpenGear provides "portshare" drivers for both Windows and Linux but they are very outdated and buggy: http://ftp.opengear.com/download/portshare/

!! A secondary problem in my case was that even though raw server was active, the firewall was blocking the port (NB: Within Opengear, setting access ports rights is done from a different webpage than the firewall :)

crististm
  • 141
  • 1
  • 5
-1

Not a direct answer for your question to use a remserial or such software, but for enterprise need like that I use some virtual port product that are created for such need. It's in big a RJ45 to serial adapter. That way you can easily have any VM or any gear that access that serial port/tty.

I know one product that do it, Perle iOLAN, but I guess it exist a lot more of such products.

In my case it was a VM that used to talk to a serial modem over a ESX cluster, as that way the VM can see it anywhere it's run on.

yagmoth555
  • 16,758
  • 4
  • 29
  • 50
  • The Opengear device does serial over ethernet so this part is covered. I'm interested in converting back to serial on my local machine. Thanks anyway. – crististm Mar 27 '17 at 19:31
  • @crististm Ah ok, didnt know that part. they don't provide driver to do it then ? as the device I paste, there is a linux driver available, that do the connection over a virtual driver/device – yagmoth555 Mar 27 '17 at 19:34
  • I can ask. However being just a Linux box I imagine there are free/open source solutions to convert telnet back to serial just like ser2net does the oposite. At least both socat and remserial suggest this through their docs – crististm Mar 27 '17 at 19:42
  • @crististm can you gave the part number of your device ? its easy to check – yagmoth555 Mar 27 '17 at 19:43
  • Yes, but that would not change much unless the solution is only to use opengear with their telnet to serial driver. But what could I do if I used ser2net instead? – crististm Mar 27 '17 at 19:56
  • @crististm yeah, but for the ser2net did you removed the opengear to do the test ? – yagmoth555 Mar 27 '17 at 22:16