OpenWrt Forum Archive

Topic: SSH through ser2net

The content of this topic has been archived on 9 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I am looking to use ser2net to establish an SSH (secure) connection between a terminal and my device. Telnet is readily supported by ser2net. I tried setting the state to raw (instead of telnet) in ser2net.conf, but this still does not allow an SSH connection (however, it still allows a Telnet connection with extra characters being displayed in the terminal).

Any thoughts on how to accomplish this? Thanks in advance.

I was faced with the same problem a few years ago.

I believe I ended up disabling telnet and just ssh'ing to openwrt and then running minicom/cu to get to the console.

Depending on your desktop system you can script it.

(Last edited by stangri on 5 Jan 2015, 21:15)

Thanks, stangri.

I should have been more specific with my application. I am looking to SSH over TCP/IP into my serial device via a PuTTY terminal on a PC. An OpenWrt cellular-to-serial router handles the communication between the terminal and my serial device; ser2net is implemented to enable the TCP/IP to serial conversion. My serial device is resource constrained, and therefore does not implement minicom nor cu. The router runs BusyBox and implements microcom (not minicom nor cu). Therefore, I was hoping for a way that I could just reconfigure ser2net to connect via SSH instead of Telnet (without having to dive into ser2net's source code).

I think you are saying for your application you just needed to ssh between the terminal on a PC and your OpenWrt device, and used minicom/cu on the OpenWrt device to access its console? Seems like if I can get cu onto my serial device I should be able to get a secure console connection to it just like you; just have to configure ser2net to point to the DB-9 port on my OpenWrt router (which connects to my serial device) instead of the serial connection to your OpenWrt device's uP console port.

I assume you tried a port tunnel:

ssh root@<router> -L 2000:<router IP>:2000

This will create a port 2000 on your PC that is a tunnel to port 2000 on the router, which leads to ser2net.  So then you would (in another process while keeping the ssh connection open) telnet to localhost:2000 on your PC.

Another approach is what stangri said, remove ser2net and install picocom, minicom, etc. instead on the router.  Then

ssh <router> "picocom -b115200 /dev/ttyUSB0"

This launches picocom on the router, which communicates with the serial port and uses your ssh session as the terminal.

In both cases the communication over the Internet between the router and the PC will be encrypted, and proper ssh login credentials will be required to open the connection.

The discussion might have continued from here.