Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const SSHClient = require("ssh2-sftp-client");
- const fs = require("fs");
- const sshOptions = {
- host: process.env.SSH_HOST,
- username: process.env.SSH_USERNAME,
- password: process.env.SSH_PASSWORD,
- passphrase: process.env.SSH_PASSPHRASE,
- remoteDir: "/default/remote/folder/",
- privateKey: fs.readFileSync(__dirname + "/path/to/key.pem")
- };
- const sshClient = new SSHClient();
- sshClient
- .connect(sshOptions)
- .then(() => {
- return sshClient.mkdir("new_folder_path");
- })
- .then(folderCreated => {
- return sshClient.end();
- })
- .then(() => {
- process.exit(0);
- })
- .catch(error => {
- console.error(error);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement