Fabric appears not to have support for using your
~/.ssh/config settings, which is annoying if you're trying to work with someone else who has a different UNIX username and different key file but may still want to push to the staging server. Adding that is in Fabric's tickets for 1.0, and I imagine it would be easy, since the Paramiko SSH library it uses already supports config file parsing.
In fact, I wrote this quick function that fixes up Fabric's
env according to what's in your
~/.ssh/config for the hosts it lists. While it'll be nice when Fabric does it, this'll do for now.
Update: I added crccheck's suggestions from the comments.
from fabric.api import * env.hosts = ['servername'] def _annotate_hosts_with_ssh_config_info(): from os.path import expanduser from paramiko.config import SSHConfig def hostinfo(host, config): hive = config.lookup(host) if 'hostname' in hive: host = hive['hostname'] if 'user' in hive: host = '%s@%s' % (hive['user'], host) if 'port' in hive: host = '%s:%s' % (host, hive['port']) return host try: config_file = file(expanduser('~/.ssh/config')) except IOError: pass else: config = SSHConfig() config.parse(config_file) keys = [config.lookup(host).get('identityfile', None) for host in env.hosts] env.key_filename = [expanduser(key) for key in keys if key is not None] env.hosts = [hostinfo(host, config) for host in env.hosts] _annotate_hosts_with_ssh_config_info()