A file upload/download tool based on SSH/SFTP, with a server management experience similar to nrm.
# Install from npm package
npm install -g tx-cli-0.1.0.tgz
# Or install from source
git clone <repo>
cd tx
npm install
npm run build
npm linkAfter installation, use the tx command.
# 1. Add a server (interactive)
tx add myserver
# 2. Switch to that server
tx use myserver
# 3. Upload files
tx push file.txt
# 4. Download files
tx pull file.txt| Command | Description |
|---|---|
tx ls |
List all servers, * marks the currently active one |
tx add <name> |
Interactively add a server |
tx del <name> |
Delete a server |
tx use <name> |
Switch the current server |
| Command | Description |
|---|---|
tx push <files...> |
Upload file(s) to remote server |
tx pull <files...> |
Download file(s) from remote server |
Optional parameters:
| Flag | Description |
|---|---|
-s <name> |
Temporarily specify a server (without changing the current server) |
-r <dir> |
Specify remote directory (push only) |
-l <dir> |
Specify local directory (defaults to current working directory) |
tx config get # View current configuration
tx config set remoteDir /var/www # Set default values
tx config get remoteDir # View default values| Key | Description |
|---|---|
remoteDir |
Default remote directory |
localDir |
Default local directory (empty means use current working directory) |
# Add multiple servers
tx add prod
tx add staging
tx add dev
# View server list
tx ls
# Output:
# dev
# * prod
# staging
# Upload files to the current server
tx push dist/app.js
tx push dist/
# Upload to a specific server's specific directory
tx push -s staging -r /var/www/html dist/app.js
# Download remote files to current directory
tx pull /var/www/html/app.js
# Download to a specific local directory
tx pull -l ./backup /var/www/html/app.js
# Set default remote directory
tx config set remoteDir /var/www/html
# Batch upload
tx push src/a.js src/b.js src/c.jsSupports two authentication methods (choose when adding a server):
- Specify private key path (defaults to
~/.ssh/id_rsa) - Supports passphrase-protected keys
- Option to save password to config when adding
- Leave empty to be prompted interactively each time you connect
Configuration is stored at ~/.config/tx/config.json, in the following format:
{
"current": "prod",
"defaults": {
"remoteDir": "/var/www/html",
"localDir": ""
},
"servers": {
"prod": {
"host": "192.168.1.100",
"port": 22,
"username": "deploy",
"authType": "key",
"privateKeyPath": "~/.ssh/id_rsa"
},
"staging": {
"host": "192.168.1.101",
"port": 22,
"username": "deploy",
"authType": "password",
"password": "secret"
}
}
}Remote directory priority: CLI argument -r > server config remoteDir > global default defaults.remoteDir
npm install
# Build
npm run build
# Watch mode
npm run watch