Discussion:
[Fab-user] Run as root without sudo and root ssh disabled
Emiliano Vazquez
2018-06-15 13:19:12 UTC
Permalink
Hi guys. I'm stuck on this.

I have some debian boxes without sudo and only my user working.

Today i do this:
1. Login to box as "myuser"
2. *$su *-
3. Ask for the root password (diferent from myuser password)
4. I got root => *#*

I can't make it work with fabric.

sudo('sh /tmp/myscript.sh') did not work

I read about using expect but i don't know if this is the "python way" to
do this.

Any hint will be apreciatted

Emiliano
Brandon Whaley
2018-06-15 14:39:30 UTC
Permalink
I think you may be able to use su by setting up a watcher for su's password
prompt and using su -c "command" via run:

http://docs.pyinvoke.org/en/latest/concepts/watchers.html#autoresponding

responder = Responder(
pattern=r"Password: ",
response="thisismysecretpassword",
)
c.run("su -c 'something-that-needs-root'", watchers=[responder])
Post by Emiliano Vazquez
Hi guys. I'm stuck on this.
I have some debian boxes without sudo and only my user working.
1. Login to box as "myuser"
2. *$su *-
3. Ask for the root password (diferent from myuser password)
4. I got root => *#*
I can't make it work with fabric.
sudo('sh /tmp/myscript.sh') did not work
I read about using expect but i don't know if this is the "python way" to
do this.
Any hint will be apreciatted
Emiliano
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
Emiliano Vazquez
2018-06-15 14:45:46 UTC
Permalink
thanks i will checkout right now!
Post by Brandon Whaley
I think you may be able to use su by setting up a watcher for su's
http://docs.pyinvoke.org/en/latest/concepts/watchers.html#autoresponding
responder = Responder(
pattern=r"Password: ",
response="thisismysecretpassword",
)
c.run("su -c 'something-that-needs-root'", watchers=[responder])
On Fri, Jun 15, 2018 at 9:19 AM Emiliano Vazquez <
Post by Emiliano Vazquez
Hi guys. I'm stuck on this.
I have some debian boxes without sudo and only my user working.
1. Login to box as "myuser"
2. *$su *-
3. Ask for the root password (diferent from myuser password)
4. I got root => *#*
I can't make it work with fabric.
sudo('sh /tmp/myscript.sh') did not work
I read about using expect but i don't know if this is the "python way" to
do this.
Any hint will be apreciatted
Emiliano
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
Emiliano Vazquez
2018-06-15 15:09:08 UTC
Permalink
I install invoke from pip, then i get this error:

TypeError: run() got an unexpected keyword argument 'watchers'

I need to import something else?

best regards i still reading ...
Post by Emiliano Vazquez
thanks i will checkout right now!
Post by Brandon Whaley
I think you may be able to use su by setting up a watcher for su's
http://docs.pyinvoke.org/en/latest/concepts/watchers.html#autoresponding
responder = Responder(
pattern=r"Password: ",
response="thisismysecretpassword",
)
c.run("su -c 'something-that-needs-root'", watchers=[responder])
On Fri, Jun 15, 2018 at 9:19 AM Emiliano Vazquez <
Post by Emiliano Vazquez
Hi guys. I'm stuck on this.
I have some debian boxes without sudo and only my user working.
1. Login to box as "myuser"
2. *$su *-
3. Ask for the root password (diferent from myuser password)
4. I got root => *#*
I can't make it work with fabric.
sudo('sh /tmp/myscript.sh') did not work
I read about using expect but i don't know if this is the "python way"
to do this.
Any hint will be apreciatted
Emiliano
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
Emiliano Vazquez
2018-06-15 15:14:53 UTC
Permalink
I think i'm running version 1 of fabric.

I will install fabric v2 and start again
Post by Emiliano Vazquez
TypeError: run() got an unexpected keyword argument 'watchers'
I need to import something else?
best regards i still reading ...
On Fri, Jun 15, 2018 at 11:45 AM Emiliano Vazquez <
Post by Emiliano Vazquez
thanks i will checkout right now!
Post by Brandon Whaley
I think you may be able to use su by setting up a watcher for su's
http://docs.pyinvoke.org/en/latest/concepts/watchers.html#autoresponding
responder = Responder(
pattern=r"Password: ",
response="thisismysecretpassword",
)
c.run("su -c 'something-that-needs-root'", watchers=[responder])
On Fri, Jun 15, 2018 at 9:19 AM Emiliano Vazquez <
Post by Emiliano Vazquez
Hi guys. I'm stuck on this.
I have some debian boxes without sudo and only my user working.
1. Login to box as "myuser"
2. *$su *-
3. Ask for the root password (diferent from myuser password)
4. I got root => *#*
I can't make it work with fabric.
sudo('sh /tmp/myscript.sh') did not work
I read about using expect but i don't know if this is the "python way"
to do this.
Any hint will be apreciatted
Emiliano
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
Jeff Forcier
2018-06-15 16:05:27 UTC
Permalink
If you encounter issues with v2 (it's still very early after release) v1
does have an 'env.prompts' setting. It's much simpler than v2's watcher
functionality, but it might still get the job done so check it out.
Post by Emiliano Vazquez
I think i'm running version 1 of fabric.
I will install fabric v2 and start again
On Fri, Jun 15, 2018 at 12:09 PM Emiliano Vazquez <
Post by Emiliano Vazquez
TypeError: run() got an unexpected keyword argument 'watchers'
I need to import something else?
best regards i still reading ...
On Fri, Jun 15, 2018 at 11:45 AM Emiliano Vazquez <
Post by Emiliano Vazquez
thanks i will checkout right now!
Post by Brandon Whaley
I think you may be able to use su by setting up a watcher for su's
http://docs.pyinvoke.org/en/latest/concepts/watchers.html#
autoresponding
responder = Responder(
pattern=r"Password: ",
response="thisismysecretpassword",
)
c.run("su -c 'something-that-needs-root'", watchers=[responder])
On Fri, Jun 15, 2018 at 9:19 AM Emiliano Vazquez <
Post by Emiliano Vazquez
Hi guys. I'm stuck on this.
I have some debian boxes without sudo and only my user working.
1. Login to box as "myuser"
2. *$su *-
3. Ask for the root password (diferent from myuser password)
4. I got root => *#*
I can't make it work with fabric.
sudo('sh /tmp/myscript.sh') did not work
I read about using expect but i don't know if this is the "python way"
to do this.
Any hint will be apreciatted
Emiliano
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
--
Jeff Forcier
Unix sysadmin; Python engineer
http://bitprophet.org
Emiliano Vazquez
2018-06-15 16:13:48 UTC
Permalink
Post by Jeff Forcier
If you encounter issues with v2 (it's still very early after release) v1
does have an 'env.prompts' setting. It's much simpler than v2's watcher
functionality, but it might still get the job done so check it out.
Hi Jeff i'm reading but is a little hard to understand fabric2 yet for me

Can you give to me any link to read about? i was looking earlier about
env.prompts but can't get this working yet.

Best regards
Post by Jeff Forcier
Post by Emiliano Vazquez
I think i'm running version 1 of fabric.
I will install fabric v2 and start again
On Fri, Jun 15, 2018 at 12:09 PM Emiliano Vazquez <
Post by Emiliano Vazquez
TypeError: run() got an unexpected keyword argument 'watchers'
I need to import something else?
best regards i still reading ...
On Fri, Jun 15, 2018 at 11:45 AM Emiliano Vazquez <
Post by Emiliano Vazquez
thanks i will checkout right now!
Post by Brandon Whaley
I think you may be able to use su by setting up a watcher for su's
http://docs.pyinvoke.org/en/latest/concepts/watchers.html#autoresponding
responder = Responder(
pattern=r"Password: ",
response="thisismysecretpassword",
)
c.run("su -c 'something-that-needs-root'", watchers=[responder])
On Fri, Jun 15, 2018 at 9:19 AM Emiliano Vazquez <
Post by Emiliano Vazquez
Hi guys. I'm stuck on this.
I have some debian boxes without sudo and only my user working.
1. Login to box as "myuser"
2. *$su *-
3. Ask for the root password (diferent from myuser password)
4. I got root => *#*
I can't make it work with fabric.
sudo('sh /tmp/myscript.sh') did not work
I read about using expect but i don't know if this is the "python
way" to do this.
Any hint will be apreciatted
Emiliano
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
--
Jeff Forcier
Unix sysadmin; Python engineer
http://bitprophet.org
Loading...