https://github.com/avin/ssh-delivery
Do fast files deploy with SFTP. Support servers chain.
https://github.com/avin/ssh-delivery
Last synced: about 1 year ago
JSON representation
Do fast files deploy with SFTP. Support servers chain.
- Host: GitHub
- URL: https://github.com/avin/ssh-delivery
- Owner: avin
- Created: 2022-06-14T11:18:53.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2025-02-13T14:45:52.000Z (over 1 year ago)
- Last Synced: 2025-04-18T10:12:31.548Z (about 1 year ago)
- Language: JavaScript
- Size: 245 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SSH-Delivery
Do fast files deploy with SFTP. Support servers chain.
## Install
```sh
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
```
```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',
// Optional: Socks5 proxy settings for connecting to the first SSH server in the chain
socksProxyHost: '127.0.0.1',
socksProxyPort: 1080,
// socksProxyUsername and socksProxyPassword are optional if your proxy requires authentication
// socksProxyUsername: 'proxyUser',
// socksProxyPassword: 'proxyPass',
},
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:
```js
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',
// Optional Socks5 proxy settings:
// socksProxyHost: '127.0.0.1',
// socksProxyPort: 1080,
// socksProxyUsername: 'proxyUser',
// socksProxyPassword: 'proxyPass',
},
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
```sh
delivery deployToWebServer
```
or with custom config path
```sh
delivery deployToWebServer -c ./custom-config.js
```
You can keep servers options with credentials in separate config