https://www.npmjs.com/package/ssh2

npm install ssh2

 ssh2文件下载:

 1 //前台命令下发
 2 app.get('/test/fileDownload', function (req, res) {
 3     var downloadPath = req.query.downloadPath;
 4     console.log(downloadPath);
 5 
 6     var conn = new Client();
 7     conn.on('ready', function() {
 8         console.log('Client :: ready');
 9         conn.sftp(function(err, sftp) {
10             if (err) throw err;
11             //sftp.fastPut('/home/admin/foo/expdat.log','/home/book/foo/expdat.log', function(err, list) {
12             sftp.fastGet('/home/book/foo/expdat.log','/home/admin/foo/expdat.log' ,function(err, result) {
13                 if (err) throw err;
14                 //console.log('----------GET  BEGIN!-------------');
15                 res.download(downloadPath);
16                 //console.log('----------GET  END!-------------');
17                 conn.end();
18             });
19         });
20     }).connect({
21         host: '192.168.0.111',
22         port: 22,
23         username: 'admin',
24         password: 'admin'
25     });
26 });
app.get('/test/fileDownload', function (req, res)

相关文章:

  • 2021-10-24
  • 2021-06-12
  • 2021-07-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-18
  • 2021-07-27
  • 2021-11-16
  • 2022-01-11
  • 2021-11-30
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案