Comments (4)
Does sudo command require password?
Below is sample, how to call it..
ssh.exec("echo sanket | sudo -S sh -c whoami", undefined,{
pty: true
})
Here sanket is sudo password
from ssh2-promise.
I'm using this to perform mkdir and it still isn't working:
try {
const x = await ssh.exec(
'echo p4$$w0rd | sudo -S sh -c mkdir /data/testdir',
undefined,
{
pty: true
}
);
} catch (error) {
console.log('error', error.toString());
}
I have initialised SSH2Promise with host, username, password.
Other non-sudo commands such as ls work e.g. const res = await ssh.exec('ls /data');
from ssh2-promise.
Fixed it. This is because I had special characters in my password, escape using "
e.g. sudo "p4$$w0rd" | sudo -S mkdir /data/testdir
from ssh2-promise.
Did you get any error.
try {
const x = await ssh.exec(
"echo p4$$w0rd | sudo -S sh -c 'mkdir /data/testdir'",
undefined,
{
pty: true
}
);
} catch (error) {
console.log('error', error.toString());
}
Please notice, how i have wrapped mkdir in single quote and outer command in double quote
and also if you do have bash in your machine, then you can use bash instead of sh.
from ssh2-promise.
Related Issues (20)
- Error on `npm install` after upgrading to v1.0.0 HOT 3
- X11 forwarding may fail if X server is listening on a Unix Socket HOT 4
- Spawn rejects on stderr HOT 4
- closeTunnel has high latency
- UnhandledPromiseRejectionWarning: TypeError: ssh2_promise_1.default is not a constructor HOT 2
- How to get the retry count? HOT 1
- Connection hopping: netcat processes are never killed
- Uncatchable rejected promise HOT 3
- tryKeyboard not working HOT 2
- Cannot create writeStream HOT 3
- `exec` - Rejected promises because of `stderr` output only provide the first chunk of data encountered HOT 1
- MaxListenersExceededWarning: Possible EventEmitter memory leak detected.
- No response from server HOT 7
- Disable Error Handling HOT 8
- can you provide some example for connect the ssh with same session and pass multiple commands using ssh2-promise HOT 2
- Authentication Fail on RHEL 9
- command result maximum size is 512 MB
- Change Request: Move @types/ssh2 devDependency to regular dependency
- Which types to use for objects - so many any types HOT 1
- SSHConnections not closing properly and SSHConnection sharing uniqueIDs
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 ssh2-promise.