Coder Social home page Coder Social logo

Comments (7)

mwilliamson avatar mwilliamson commented on August 25, 2024

Thanks for the kind words. Could you point me towards the section of the paramiko docs that explain how to pass a password to sudo? What happens if you just write to stdin?

from spur.py.

foxbunny avatar foxbunny commented on August 25, 2024

I don't see any response from OP, so I'll mention that writing to STDIN followed by a newline works just fine for me.

from spur.py.

mwilliamson avatar mwilliamson commented on August 25, 2024

Good to know, thanks!

from spur.py.

preems avatar preems commented on August 25, 2024

Thanks. That worked for me too.
Does this also supports shell features like pipes and reading from bash environment variables ?

from spur.py.

mwilliamson avatar mwilliamson commented on August 25, 2024

You'd have to explicitly start a bash shell to get access to bash shell features e.g.

shell.run(["sh", "-c", "echo $PATH"])

It seems as if there's no issue here, so I'm closing.

from spur.py.

eddawley avatar eddawley commented on August 25, 2024

I think this issue should be reopened as spur does not really support SUDO commands that require passwords. The problem is that there is no way to determine if the connection is waiting on a password from the user so there's no way to tell if you need to write the password to stdin. This is an inherent problem with the fact that SshProcess() does not expose stdout until the process has completed.

One workaround is that you can run the following first to see if a password will be expected:
ssh.run(['sudo', '-n', 'whoami'], allow_error=True).return_code

That workaround is suboptimal though because sudo has a timeout for cached passwords so you never know when you'll run another command that needs you to resend the password.

from spur.py.

mwilliamson avatar mwilliamson commented on August 25, 2024

This is an inherent problem with the fact that SshProcess() does not expose stdout until the process has completed.

You can pass in a file-like object in the stdout argument, which will be written to as the process runs.

from spur.py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.