nodejs登录服务器,并操作服务器
const ssh2 = require('ssh2');
const fs = require('ssh2-fs');
const mineType = require('mime-types');
connection = new ssh2();
connection.connect({
"host": "172.168.11.57",
"username": "root",
"password": "T7oWwCaa92FG"
});
connection.on('error', function(err) {
connection.end()
});
connection.on('ready', function() {
const filePath = '/home/Assistant/backend/upload/logo_1557735274728.jpg';
let data = fs.readFileSync(filePath);
let bufferData = new Buffer(data, 'base64');
let base64 = 'data:' + mineType.lookup(filePath) + ';base64,' + data;
console.log(11, base64)
});
此方法太污