chore: sync ops/put.js

This commit is contained in:
admin committed 2026-11-24 17:06:10 +00:00
1 parent 63c603ddd6
commit fbe792a2f5
1 file changed
+18
+18
View File
@@ -0,0 +1,18 @@
// 上传文件: node put.js <ub1|ub2|ub3> <localPath> <remotePath>
const { Client } = require("ssh2");
const HOSTS = { ub1: "192.168.50.177", ub2: "192.168.50.161", ub3: "192.168.50.207" };
const [alias, lp, rp] = [process.argv[2], process.argv[3], process.argv[4]];
const conn = new Client();
conn.on("keyboard-interactive", (n, d, i, l, next) => next(null, ["123456"]))
.on("ready", () => {
conn.sftp((e, sftp) => {
if (e) { console.error("SFTP_ERR", e.message); process.exitCode = 1; conn.end(); return; }
sftp.fastPut(lp, rp, (err) => {
if (err) { console.error("PUT_ERR", err.message); process.exitCode = 1; }
else console.log("PUT_OK", rp);
conn.end();
});
});
})
.on("error", (e) => { console.error("SSH_ERR", e.message); process.exitCode = 127; })
.connect({ host: HOSTS[alias] || alias, port: 22, username: "czk", password: "123456", readyTimeout: 8000 });