'In node js project, how to write a command which runs on linux command line
I am working on a node js project and in this project I need to write a command that will run on the linux command line. The command is
ssh -L 0.0.0.0:9999:hostname:5905 username@hostname
I have tried the cmd.run() function and it is running the command but as this is a ssh command it is asking for a password and the project is struck on that.
Someone please help me.
Solution 1:[1]
If wanted to do ssh without it asking for password, you may do key exchanges (copying yours public key to target host), so it will authenticate you with the key directly.
Regarding using ssh for nodejs program, would suggest use a nodejs wrapper library of ssh for it, as it already handles many edge cases of interacting with the commandline.
One of the wrapper libraries you may take a look at is node-ssh, there is already some examples that you can refer to and try out.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Horace Lee |
