fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fab-user] Key-based authentication and sudo


From: thatmanagain
Subject: [Fab-user] Key-based authentication and sudo
Date: Thu, 25 Sep 2008 09:26:51 -0400

Hi,

I'm a new Fabric user, and a fan. Good stuff. :)

I noticed in the user guide, this paragraph:

"If you have a private key that the servers will acknowledge, then Fabric will automatically pick it up, and if a password is required for unlocking that key, then Fabric will ask that password. This default behavior should work for most people, but if you use password-less keys, then note the caveat that Fabric won't ask for a password and this in turn means that the sudo() operation won't be able to parse a password to the sudo command on the remote hosts. To counter this, you need to specify, on the remote hosts, the commands you need for deployment as sudo'able without a password."

I thought it might be worthwhile to point out that there's an alternative to making those commands sudo'able without a password:


import getpass
def sudo_cmd():
    "Run a command with sudo. Prompts for your password first."
    set (fab_password=getpass.getpass())
    prompt('command', 'Command')
    sudo(get('command'))

The above snippet will work with ssh-key authentication, and has the added bonus of not echoing your sudo password on the screen.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]