Search code examples
pythonfabric

Switching user in Fabric using with settings(user='user')


I'm trying to switch user in Fabric:

def check_user():
    with settings(user='linevich'):
        run("whoami")  

Result:

[[email protected]:10022] Executing task 'check_user'
[[email protected]:10022] run: whoami
[[email protected]:10022] Login password for 'linevich': 
[[email protected]:10022] out: root

What's wrong?
(No, I don't want to use sudo() instead.)


Solution

  • Solution: I used following command to launch script:

    fab -H [email protected]:10022
    

    Right way - run it without setting username:

    fab -H 127.0.0.1:10022