Switching user in Fabric

后端 未结 3 390
迷失自我
迷失自我 2021-01-01 15:41

I have a problem when using Fabric to mimic my SSH workflow to deploy my web application.

Here\'s my usual flow of commands when I SSH to a server:

  1. SS
3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-01 16:21

    The way I achieve this is with

    from fabric.api import settings
    
    with settings(user='otheruser'):
        ...
    

    You will be prompted for the password of otheruser, though only once. So it is not equivalent so sudo su otheruser, where root logs in to the user account without a password, but is is a simple way to switch between users in your script, only typing each password once

提交回复
热议问题