Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tx — SSH File Transfer CLI

A file upload/download tool based on SSH/SFTP, with a server management experience similar to nrm.

Installation

# 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 link

After installation, use the tx command.

Quick Start

# 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 Reference

Server Management

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

File Transfer

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)

Default Configuration

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)

Usage Examples

# 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.js

SSH Authentication

Supports two authentication methods (choose when adding a server):

Key Authentication

  • Specify private key path (defaults to ~/.ssh/id_rsa)
  • Supports passphrase-protected keys

Password Authentication

  • Option to save password to config when adding
  • Leave empty to be prompted interactively each time you connect

Configuration File

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

Development

npm install
# Build
npm run build
# Watch mode
npm run watch

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages