Epe*_*eli 36
用纯JavaScript编写的用于node.js的SSH2客户端模块
https://github.com/mscdex/ssh2
还要检查这个包装器
https://github.com/mikeal/sequest
Epe*_*eli 16
如果您需要使用密码进行登录,Node.js子进程将不会执行,因为OpenSSH客户端不会从stdin读取密码,而是从伪终端读取密码.
var pty = require("pty.js");
var term = pty.spawn("ssh", ["username@localhost", "whoami"]);
term.on("data", function(data) {
console.log("Incoming: " + data.toString());
});
// Wait a sec before sending the password. For proper implementation
// you should wait for the password prompt.
setTimeout(function(){
term.write("mypassword\n");
}, 1000);
Run Code Online (Sandbox Code Playgroud)
话虽这么说,如果可能的话,你应该总是使用SSH密钥对.
Van*_*yen 12
以下是另外两个选项:
客户端非常可靠,基本适用于一般用途.节点控制更适合于对许多机器进行并行,异步控制(即sys-admin工作).
| 归档时间: |
|
| 查看次数: |
58554 次 |
| 最近记录: |