-
-
Save aubricus/5157931 to your computer and use it in GitHub Desktop.
Using Fabric to connect to the remote server via an ssh config.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fabric.api import env | |
env.use_ssh_config = True | |
env.forward_agent = True | |
env.roledefs = { | |
# key # hostname from config | |
'foo': ['foo.production'], | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ForwardAgent yes | |
Host foo.production | |
User username | |
HostName foo.com | |
IdentityFile /path/to/.ssh/keyname_rsa |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fabric.api import local, run, task, roles | |
@task | |
def local_uname(): | |
local('uname -a') | |
@roles('foo') | |
@task | |
def remote_uname(): | |
run('uname -a') |
Very helpful, thanks a lot !
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
References: