Skip to content

Instantly share code, notes, and snippets.

Forked from yuvadm/
Last active Mar 4, 2020
What would you like to do?
Using Fabric to connect to the remote server via an ssh config.
from fabric.api import env
env.use_ssh_config = True
env.forward_agent = True
env.roledefs = {
# key # hostname from config
'foo': ['foo.production'],
ForwardAgent yes
Host foo.production
User username
IdentityFile /path/to/.ssh/keyname_rsa
from fabric.api import local, run, task, roles
def local_uname():
local('uname -a')
def remote_uname():
run('uname -a')

This comment has been minimized.

Copy link
Owner Author

@aubricus aubricus commented Mar 14, 2013

The "ssh config" is usually located in ~/.ssh/ and named "config". This gist should support encrypted and unencrypted keys. If you're using an encrypted key you can add the key to ssh-agent to avoid a password request every time you connect to the remote.



This comment has been minimized.

Copy link

@mlan24 mlan24 commented Apr 18, 2018

Very helpful, thanks a lot !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment