Socket
Socket
Sign inDemoInstall

ssh-delivery

Package Overview
Dependencies
45
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

ssh-delivery

Do fast files deploy with SFTP. Support servers chain.


Version published
Maintainers
1
Weekly downloads
3
Install size
3.78 MB

Weekly downloads

Readme

Source

SSH-Delivery

Do fast files deploy with SFTP. Support servers chain.

Install

npm install -g ssh-delivery

Configure

Create config with tasks and servers declaration. Default config file names :

.deliveryrc
.deliveryrc.js
.delivery.config.js
delivery.config.js
const fs = require('fs');
const path = require('path');

module.exports = {
  // SSH servers (all server options see at https://github.com/mscdex/ssh2#client-methods `connect` method)
  // Upload destination servers should support SFTP. Gateway servers should support port forwarding.
  servers: {
    gate: {
      alias: 'gate',
      host: 'gate.myweb.com',
      username: 'root',
      password: 'secret',
    },
    web: {
      host: 'myweb.com',
      port: 41022,
      username: 'root',
      privateKey: fs.readFileSync(path.resolve(os.homedir(), '.ssh', 'id_rsa')),
      passphrase: 'secret',
      via: 'gate', // Connection to this server will be made via 'gate' server
    },
  },

  // Delivery tasks
  tasks: {
    deployToWebServer: {
      // Commands before uploading
      before: {
        run: ['npm run build'],
      },

      // Files to upload
      src: {
        path: './build/',
      },

      // Where should upload
      dst: {
        server: 'web', // server name from servers-section
        path: '/var/www/html', // path on remote server
      },

      // Commands after uploading
      after: {
        run: ['rm -rf ./build'],
      },
    },
  },
};

You can keep servers options secure in your home directory. Create $HOME/.delivery.js with content like this:

const fs = require('fs');
const os = require('os');
const path = require('path');

module.exports = {
  servers: {
    gate: {
      alias: 'gate',
      host: 'gate.myweb.com',
      username: 'root',
      password: 'secret',
    },
    web: {
      host: 'myweb.com',
      port: 41022,
      username: 'root',
      privateKey: fs.readFileSync(path.resolve(os.homedir(), '.ssh', 'id_rsa')),
      passphrase: 'secret',
      via: 'gate', // Connection to this server will be made via 'gate' server
    },
  },
}

and use serves gate and web in your separate configs without redeclaration.

Run

Run static task with

delivery deployToWebServer

or with custom config path

delivery deployToWebServer -c ./custom-config.js

You can keep servers options with credentials in separate config

Keywords

FAQs

Last updated on 20 Feb 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc