Sunday 13 July 2014

Script to automate ssh

Some of you might be aware of the fact that you could use sshpass on linux to achieve this job, but for mac users unfortunately brew doesn't provide you with sshpass because they think it is spoils ssh's security. Anyway, you could always download the source code of sshpass and build it yourself. If your lazy, use this script. Uses expect to make non-interactive ssh connection. You could provide the password as an argument to make it more secure.

The point you could take away from this post is expect can be used to automate interacting with programs. Hence, you could do wonders interacting with ANY command or code which executes in the terminal and interacts via STDIN/STDOUT.