Small Node/TypeScript utility to upload a deployment zip to a remote Linux server over SSH/SFTP and execute a provided deployment script as root.
- Node.js 18+ (used both for development and runtime).
- Remote host reachable via password-based SSH.
server_profiles.jsonanddeployment_profiles.jsonpresent alongside the compiled output/binary (the CLI reads from the working directory in dev, or the executable directory when packaged).
npm installnpm run buildto emit compiled files todist/.
Two JSON files define targets and deployments:
-
server_profiles.jsonname: string identifier.serverIp: hostname or IP.sshUsername/sshPassword: SSH credentials.sshPort: SSH port (number).rootStyle:"sudoSu"(echo password to sudo) or"suRoot"(usesu - root).rootPassword: password used for the root escalation method.
-
deployment_profiles.jsonname: string identifier.serverProfile: matches aserver_profiles.jsonentry.zipName: remote filename (without.zip) to place in the user’s home.scriptName: script to execute after upload (expected to live in the user’s home).
Example snippets:
[
{
"name": "prod-server",
"serverIp": "203.0.113.10",
"sshUsername": "deploy",
"sshPassword": "********",
"sshPort": 22,
"rootStyle": "sudoSu",
"rootPassword": "********"
}
][
{
"name": "prod-app",
"serverProfile": "prod-server",
"zipName": "release",
"scriptName": "deploy.sh"
}
]Run after building (or against ts-node in dev):
node dist/cli.js -d <deploymentProfile> <zip>
Flags/args:
-d, --deploy-profile <name>: deployment profile to use (itsserverProfilelinks the server).<zip>: path to the local zip file to upload.
What happens:
- Profile files are loaded. The deployment profile’s
serverProfileis resolved to a server entry. - Zip is uploaded to
/home/<sshUsername>/<zipName>.zip. - Deployment script is executed as root using the selected
rootStyle.
npm run pkgbuilds TypeScript and creates a self-contained executable (dist/deploy.exeby default). Ensure the profile JSON files are copied next to the binary.
- Passwords are read from the profile files; store and distribute them securely.
- The root password is echoed into shell commands—limit access to the executable and config files.
- Scripts run as root; review deployment scripts carefully before use.
- Clone:
git clone https://github.com/shessafridi/ssh-deploy.git - Install deps:
npm install - Build executable:
npm run pkg(outputsdist/deploy.exe) - (Optional) Add the executable directory to your PATH for easy use.
- Create
server_profiles.jsonanddeployment_profiles.jsonnext to the executable. Example contents:
[
{
"name": "dev-server",
"serverIp": "203.0.113.10",
"sshUsername": "deploy",
"sshPassword": "ssh-pass",
"sshPort": 22,
"rootStyle": "sudoSu",
"rootPassword": "root-pass"
}
][
{
"name": "dev-app",
"serverProfile": "dev-server",
"zipName": "release",
"scriptName": "deploy.sh"
}
]- Run the CLI (from the directory containing the executable and the JSON files):
./dist/deploy.exe -d dev-app ./release.zip