Comments (7)
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.
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.
Good to know, thanks!
from spur.py.
Thanks. That worked for me too.
Does this also supports shell features like pipes and reading from bash environment variables ?
from spur.py.
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.
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.
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)
- Infinite Loop in the _read_init_initialization_line function HOT 6
- Add close() to shells HOT 3
- How to pass a variable inside shell.run or shell.spawn HOT 4
- Add ability to specify pty width/height/term
- check_call and check_output HOT 4
- get/put/read_text/read_bytes/write_text/write_bytes/mkdir HOT 10
- send_signal() only applies to parent process HOT 2
- Concrete Minimal Shell Implementation HOT 10
- Add spur to awesome-python HOT 1
- Shell.run() Errors on sudo sed command HOT 2
- Spur fails with message "no handlers could be found for logger "paramiko.transport" HOT 3
- spur fails to connect but with same configuration paramiko works HOT 3
- test failures with python 3.8 HOT 4
- spur.results.RunProcessError: return code: 127 HOT 3
- Add spur to conda-forge HOT 1
- paramiko.ssh_exception.SSHException: Channel closed.
- ~/.ssh/config is being ignored
- stderr output: b'sudo: sorry, you must have a tty to run sudo\n' HOT 1
- Unimplemented method HOT 8
- 0.3.22: test suite uses outdated `nose` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spur.py.