You may be interested in Fabric
Fabric is a Python library and command-line tool for streamlining the
use of SSH for application deployment or systems administration tasks.
It provides a basic suite of operations for executing local or remote
shell commands (normally or via sudo) and uploading/downloading files,
as well as auxiliary functionality such as prompting the running user
for input, or aborting execution.
You may also be interested in drush for command line access to Drupal.
e.g, some relevant drush commands:
archive-dump Backup your code, files, and database into a single file.
archive-restore Expand a site archive into a Drupal web site.
core-rsync (rsync) Rsync the Drupal tree to/from another server using ssh.
or both :)