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

264 views Asked by At

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.)

1

There are 1 answers

0
Anton Linevych On BEST ANSWER

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