Python script - connect to SSH and run command
Use paramiko or the libssh2 python bindings.
Use paramiko
, see http://jessenoller.com/2009/02/05/ssh-programming-with-paramiko-completely-different/ for a through example of using it.
now the popular solution is Fabric