Hi Brett,

Currently, Fabric's operations like run() and sudo() just look at
env.host_string to determine which connection to use (and these are
cached.)

So to force a new connection as a different user, simply set
env.host_string to us...@current_host:current_port, and subsequent
calls to operations will use that new connection. (Eventually the
other env vars will be more intelligently used -- right now they're
used for defaults or are effectively read-only.)

A one-time overwrite of that setting will make the switch for the rest
of the session/script; or you can use the context manager to effect
the change only for a single block of code, e.g.:

    @hosts('us...@myhost')
    def foo():
        # Connecting as userA
        run('something')
        sudo('something else')
        with settings(host_string='us...@myhost'):
            # Connecting as userB
            run('something as user B')
        # Connecting as userA again
        run('yet another something')

For more details on how host connections work, see the 'Usage docs'
section of docs.fabfile.org.

Best,
Jeff

On Mon, Mar 22, 2010 at 6:22 AM, Brett Haydon
<brett.hay...@unswpress.com.au> wrote:
> I am trying to switch ssh users from A to B and then remove user A on
> Ubuntu, but it always says that account A is in use.
> I don't seem to be able to explicitly log the user out.
> Is there a way to effectively do this?
>
> Brett H
>
>
>
>
>
>
>
> _______________________________________________
> Fab-user mailing list
> Fab-user@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/fab-user
>
>



-- 
Jeff Forcier
Unix sysadmin; Python/Ruby developer
http://bitprophet.org


_______________________________________________
Fab-user mailing list
Fab-user@nongnu.org
http://lists.nongnu.org/mailman/listinfo/fab-user

Reply via email to