Ubuntu – SSH into Ubuntu over Serial port

serial portssh

I have connected to my Ubuntu box using its serial port on windows(using putty connection is working fine.)

According to the question https://serverfault.com/questions/892892/how-to-use-ssh-over-serial-without-using-pppd-or-how-to-transfer-tcp-over-ser,
it appears I should be able to SSH into the machine over a serial port.

What packages are needed or alternatively how do I set this up?

http://patrickst.blogspot.com/2011/11/tcpip-over-slip-on-gnulinux-ubuntu.html

https://learn.adafruit.com/welcome-to-circuitpython/advanced-serial-console-on-mac-and-linux

Best Answer

SSH is meant to accept (secure) connections over TCP/IP. To use SSH over a serial port, you'd need something acting as a TCP client and "forwarding" data from/to the serial port, such as socat.

This (source) should be enough, assuming /dev/ttyS1 is your serial port, 115200 is the desired baud rate ("Speed" when using PuTTY for Serial connection) and you have sshd listening on port 22 (which is the default):

socat -d -d tcp:127.0.0.1:22 file:/dev/ttyS1,b115200

-d -d, according to the manual:

Prints fatal, error, warning, and notice messages.

I have not tested this, as I do not have a serial port at the moment.

If you just need login and run shell commands over the serial port, you can run getty, agetty or even screen on a serial port. The SerialConsoleHowto guide is outdated, but this answer might help.