小编ahl*_*lev的帖子

nodejs exec ssh 挂起

我希望我的 Nodejs 应用程序执行一行命令并退出。该命令用于在远程计算机上创建远程端口转发。

const exec = require("child_process").exec;

let script = "ssh -i cert.pem ubuntu@ec2 -R 9000:localhost:22 -S /tmp/.ssh-ec2 -M -fN ssh-ec2";

exec(script, (error, stdout, stderr) => {
      console.debug(stdout);
});
Run Code Online (Sandbox Code Playgroud)

节点测试.js

它挂在那里;但如果我在终端中运行纯命令。

ssh -i cert.pem ubuntu@ec2 -R 9000:localhost:22 -S /tmp/.ssh-ec2 -M -fN ssh-ec2

它退出了。

我想念什么?

ssh node.js

5
推荐指数
1
解决办法
616
查看次数

标签 统计

node.js ×1

ssh ×1