scp-next 1.0.15 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
`scp-next` is an SCP-style command-line tool and library for secure file transfers over SSH.
|
|
19
19
|
It uses SFTP internally through `ssh2-sftp-client` instead of implementing SCP or SFTP protocols manually.
|
|
20
|
-
Developer documentation is available at
|
|
20
|
+
Developer documentation is available at [GitHub Pages](https://chengchuu.github.io/scp-next/).
|
|
21
21
|
|
|
22
22
|
## Contents
|
|
23
23
|
|
|
@@ -51,7 +51,7 @@ npm install scp-next
|
|
|
51
51
|
|
|
52
52
|
## Quick Start
|
|
53
53
|
|
|
54
|
-
Upload
|
|
54
|
+
Upload a directory:
|
|
55
55
|
|
|
56
56
|
```bash
|
|
57
57
|
scp-next upload ./dist /var/www/example \
|
|
@@ -61,15 +61,18 @@ scp-next upload ./dist /var/www/example \
|
|
|
61
61
|
--recursive
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
Download
|
|
64
|
+
Download a file:
|
|
65
65
|
|
|
66
66
|
```bash
|
|
67
67
|
scp-next download /var/log/example.log ./logs/example.log \
|
|
68
68
|
--host your-host \
|
|
69
69
|
--username your-username \
|
|
70
|
-
--
|
|
70
|
+
--password your-password
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
+
Password arguments are convenient, but they may be exposed through shell history and process listings.
|
|
74
|
+
Prefer `SCP_NEXT_PASSWORD`, SSH agents, or protected private-key files for shared or production environments.
|
|
75
|
+
|
|
73
76
|
Use the library:
|
|
74
77
|
|
|
75
78
|
```ts
|
|
@@ -78,7 +81,7 @@ import { upload } from "scp-next";
|
|
|
78
81
|
await upload({
|
|
79
82
|
host: process.env.SCP_NEXT_HOST,
|
|
80
83
|
username: process.env.SCP_NEXT_USERNAME,
|
|
81
|
-
|
|
84
|
+
password: process.env.SCP_NEXT_PASSWORD,
|
|
82
85
|
localPath: "./dist",
|
|
83
86
|
remotePath: "/var/www/example",
|
|
84
87
|
recursive: true,
|
|
@@ -108,21 +111,66 @@ Destination paths follow familiar `cp`/`scp` behavior. If the destination exists
|
|
|
108
111
|
|
|
109
112
|
### Upload Examples
|
|
110
113
|
|
|
114
|
+
Preview a recursive deploy before connecting:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
scp-next upload ./dist /var/www/example \
|
|
118
|
+
--host your-host \
|
|
119
|
+
--username your-username \
|
|
120
|
+
--password your-password \
|
|
121
|
+
--recursive \
|
|
122
|
+
--dry-run
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Deploy with overwrite and verbose diagnostics:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
scp-next upload ./dist /var/www/example \
|
|
129
|
+
--host your-host \
|
|
130
|
+
--username your-username \
|
|
131
|
+
--password your-password \
|
|
132
|
+
--recursive \
|
|
133
|
+
--overwrite \
|
|
134
|
+
--verbose
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Use an encrypted private key:
|
|
138
|
+
|
|
111
139
|
```bash
|
|
112
140
|
scp-next upload ./dist /var/www/example \
|
|
113
141
|
--host your-host \
|
|
114
142
|
--username your-username \
|
|
115
143
|
--private-key-file ~/.ssh/id_ed25519 \
|
|
144
|
+
--passphrase your-passphrase \
|
|
116
145
|
--recursive
|
|
117
146
|
```
|
|
118
147
|
|
|
119
148
|
### Download Examples
|
|
120
149
|
|
|
150
|
+
Download a remote directory recursively:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
scp-next download /var/log/example ./logs/example \
|
|
154
|
+
--host your-host \
|
|
155
|
+
--username your-username \
|
|
156
|
+
--password your-password \
|
|
157
|
+
--recursive
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Download and overwrite an existing local file:
|
|
161
|
+
|
|
121
162
|
```bash
|
|
122
163
|
scp-next download /var/log/example.log ./logs/example.log \
|
|
123
164
|
--host your-host \
|
|
124
165
|
--username your-username \
|
|
125
|
-
--
|
|
166
|
+
--password your-password \
|
|
167
|
+
--overwrite
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Run a configured download job:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
scp-next run download-logs --config ./scp-next.config.json
|
|
126
174
|
```
|
|
127
175
|
|
|
128
176
|
### CLI Options
|
|
@@ -159,7 +207,7 @@ import { upload } from "scp-next";
|
|
|
159
207
|
await upload({
|
|
160
208
|
host: process.env.SCP_NEXT_HOST,
|
|
161
209
|
username: process.env.SCP_NEXT_USERNAME,
|
|
162
|
-
|
|
210
|
+
password: process.env.SCP_NEXT_PASSWORD,
|
|
163
211
|
localPath: "./dist",
|
|
164
212
|
remotePath: "/var/www/example",
|
|
165
213
|
recursive: true,
|
|
@@ -176,7 +224,7 @@ async function main() {
|
|
|
176
224
|
await download({
|
|
177
225
|
host: process.env.SCP_NEXT_HOST,
|
|
178
226
|
username: process.env.SCP_NEXT_USERNAME,
|
|
179
|
-
|
|
227
|
+
password: process.env.SCP_NEXT_PASSWORD,
|
|
180
228
|
remotePath: "/var/log/example.log",
|
|
181
229
|
localPath: "./logs/example.log"
|
|
182
230
|
});
|
|
@@ -196,7 +244,7 @@ import { createClient } from "scp-next";
|
|
|
196
244
|
const client = createClient({
|
|
197
245
|
host: process.env.SCP_NEXT_HOST,
|
|
198
246
|
username: process.env.SCP_NEXT_USERNAME,
|
|
199
|
-
|
|
247
|
+
password: process.env.SCP_NEXT_PASSWORD
|
|
200
248
|
});
|
|
201
249
|
|
|
202
250
|
try {
|
|
@@ -234,12 +282,10 @@ await upload({
|
|
|
234
282
|
|
|
235
283
|
### Configuration Files
|
|
236
284
|
|
|
237
|
-
`scp-next`
|
|
285
|
+
Use `scp-next.config.json` in the current directory. `scp-next` also auto-detects these rc-style filenames: `.scp-nextrc`, `.scp-nextrc.json`.
|
|
238
286
|
|
|
239
287
|
```text
|
|
240
288
|
scp-next.config.json
|
|
241
|
-
.scp-nextrc
|
|
242
|
-
.scp-nextrc.json
|
|
243
289
|
```
|
|
244
290
|
|
|
245
291
|
Use `--config` for an explicit path:
|
|
@@ -264,7 +310,7 @@ Example:
|
|
|
264
310
|
"host": "your-host",
|
|
265
311
|
"port": 22,
|
|
266
312
|
"username": "your-username",
|
|
267
|
-
"
|
|
313
|
+
"password": "your-password"
|
|
268
314
|
},
|
|
269
315
|
"transfer": {
|
|
270
316
|
"recursive": true,
|
|
@@ -275,6 +321,8 @@ Example:
|
|
|
275
321
|
}
|
|
276
322
|
```
|
|
277
323
|
|
|
324
|
+
Do not commit configuration files containing real passwords. Prefer `SCP_NEXT_PASSWORD` or another protected secret source for shared repositories and deployment environments.
|
|
325
|
+
|
|
278
326
|
Configuration file options:
|
|
279
327
|
|
|
280
328
|
| Key | Description |
|
|
@@ -298,7 +346,7 @@ and `hostFingerprint` are also supported for simple configuration files, but `se
|
|
|
298
346
|
"host": "your-host-a",
|
|
299
347
|
"port": 22,
|
|
300
348
|
"username": "your-username-a",
|
|
301
|
-
"
|
|
349
|
+
"password": "your-password-a"
|
|
302
350
|
},
|
|
303
351
|
"staging": {
|
|
304
352
|
"host": "your-host-b",
|
|
@@ -324,7 +372,7 @@ Jobs use `source` and `destination`; the `operation` determines which path is lo
|
|
|
324
372
|
"production": {
|
|
325
373
|
"host": "your-host",
|
|
326
374
|
"username": "your-username",
|
|
327
|
-
"
|
|
375
|
+
"password": "your-password"
|
|
328
376
|
}
|
|
329
377
|
},
|
|
330
378
|
"jobs": {
|
|
@@ -373,7 +421,7 @@ Bash:
|
|
|
373
421
|
```bash
|
|
374
422
|
export SCP_NEXT_HOST="your-host"
|
|
375
423
|
export SCP_NEXT_USERNAME="your-username"
|
|
376
|
-
export
|
|
424
|
+
export SCP_NEXT_PASSWORD="your-password"
|
|
377
425
|
scp-next upload ./dist /var/www/example --recursive
|
|
378
426
|
```
|
|
379
427
|
|
|
@@ -382,7 +430,7 @@ PowerShell:
|
|
|
382
430
|
```powershell
|
|
383
431
|
$env:SCP_NEXT_HOST = "your-host"
|
|
384
432
|
$env:SCP_NEXT_USERNAME = "your-username"
|
|
385
|
-
$env:
|
|
433
|
+
$env:SCP_NEXT_PASSWORD = "your-password"
|
|
386
434
|
scp-next upload .\dist /var/www/example --recursive
|
|
387
435
|
```
|
|
388
436
|
|
|
@@ -454,7 +502,7 @@ try {
|
|
|
454
502
|
await upload({
|
|
455
503
|
host: process.env.SCP_NEXT_HOST,
|
|
456
504
|
username: process.env.SCP_NEXT_USERNAME,
|
|
457
|
-
|
|
505
|
+
password: process.env.SCP_NEXT_PASSWORD,
|
|
458
506
|
localPath: "./dist",
|
|
459
507
|
remotePath: "/var/www/example"
|
|
460
508
|
});
|