SSH does not run on the serial port, it runs a gettygetty directly. You can interact with it in any program that can talk to a serial device like using pyserial with python. Using this, you can open a serial connection and sentsend it the characters you would normally type to interact with the gettygetty. You can read and parse responses as well to make it less error prone.
But, this is just scripting an interactive prompt, it is not the most reliable way to set up a piPi. For example, if a character gets dropdropped (which can happen on a serial line) then it can mess up the commands you are trying to enter.
If you are on, or have, a linuxLinux system available (useyou can use virtualboxVirtualBox and vagrantVagrant to easily create one), it is better to chrootchroot
into the image and set it up from your main pcPC. See this guide for more detailed instructioninstructions on how to do this with the archlinuxarmarchlinuxarm
image, though the steps are similar for raspbianRaspbian (mostly you can skip to the chrootchroot
steps). Also, this guide for a more detailed explication of creating the chrootchroot
.