SSH does not run on the serial port, it runs a getty 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 send it the characters you would normally type to interact with the getty. 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 Pi. For example, if a character gets dropped (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 Linux system available (you can use VirtualBox and Vagrant to easily create one), it is better to chroot
into the image and set it up from your main PC. See this guide for more detailed instructions on how to do this with the archlinuxarm
image, though the steps are similar for Raspbian (mostly you can skip to the chroot
steps). Also, this guide for a more detailed explication of creating the chroot
.