[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fab-user] Changing user with sudo and running commands as new user
From: |
Herman Schistad |
Subject: |
[Fab-user] Changing user with sudo and running commands as new user |
Date: |
Sun, 21 Oct 2012 14:30:14 +0200 |
Hi,
I got the following deployment scenario:
(ssh) (ssh)
localhost => login_server => deployment_server => change
user (with sudo) => change folder to project => run git pull and
deployment commands
Ok, so the first part is fine. I know tunnelling is coming in
Fabric 1.5, but in the meantime I found the following solution (which
works):
http://www.alleyinteractive.com/blog/ssh-tunnel-fabric/
My problem, however, is the second part. That is the following steps on
the remote host:
1. Change user with «sudo su username -s /bin/bash»
2. As this new user, change folder to ~/productioncode/
3. In this folder run git pull and other arbitrary commands (hopefully
also a prompt after a new git tag for the deployment)
When running my code at this moment fabric runs the sudo su command, but
then seems to halt the following operations (more precicely the «with cd
[path]» command) by giving me a shell as this new user, as if I was
logged on to the box.
Pressing Ctrl+D stops the shell and the process seems to be continuing,
but to a massive fail since I'm no longer logged in as the deployment
user.
My code, for the interested:
https://gist.github.com/3926847
I would gladly accept recommendations on how to enable my scenario
depicted above and then especially changing user with sudo and running
commands as this user afterwards.
Thanks for any help or comments,
Sincerly,
Herman Schistad
ITK, Samfundet Trondheim
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fab-user] Changing user with sudo and running commands as new user,
Herman Schistad <=