This guide is designed for the development, support, and operations (DevOps) teams to securely deploy new versions of app-controller on a Linux board, without access to the system's main keys.
Allowing the support/development team to:
- Upload wheel and wheelhouse files
- Execute the service update script
Without full shell access or system public keys.
- No one except the system owner receives the main SSH key.
- A dedicated deployment key is used.
- The deployment key can only execute a specific script.
- System access is limited to one directory and one operation.
In PowerShell (in the project folder):
ssh-keygen -t rsa -b 4096 -f .\scripts\install_script\remote\app-deploy-key -C "app-deploy-key"Generated files:
- app-deploy-key → Private key (Keep secret!)
- app-deploy-key.pub → Public key (For the Linux server)
💡 Do not add these files to Git!
Add to .gitignore:
scripts/install_script/remote/app-deploy-key
sudo adduser --disabled-password --gecos "" deploysudo mkdir -p /home/deploy/.ssh
sudo nano /home/deploy/.ssh/authorized_keysWrite the file content like this (one complete line):
command="/usr/local/bin/app-deploy-guard.sh",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAAB3NzaC1yc2E... app-deploy-keyAAAAB3NzaC1yc2E... with the actual content of app-deploy-key.pub.
sudo chown -R deploy:deploy /home/deploy/.ssh
sudo chmod 700 /home/deploy/.ssh
sudo chmod 600 /home/deploy/.ssh/authorized_keyssudo nano /usr/local/bin/app-deploy-guard.shContent:
#!/bin/bash
# Only allow update execution with valid file name
PROJECT_DIR="/root/workspace/app_controller"
UPDATE_SCRIPT="/root/update_app.sh"
# Check allowed pattern: Only execute update_app.sh with a .whl file
if [[ "$SSH_ORIGINAL_COMMAND" =~ ^bash\ /root/update_app\.sh\ [a-zA-Z0-9._-]+\.whl$ ]]; then
# Extract file name
WHL_FILE="${SSH_ORIGINAL_COMMAND#* }"
exec "$UPDATE_SCRIPT" "$WHL_FILE"
else
echo "❌ Unauthorized access. Only app-controller update is allowed."
exit 1
fiGrant execution permission:
sudo chmod +x /usr/local/bin/app-deploy-guard.shIn the file: scripts/install_script/remote/Deploy-App.ps1
Change the ssh and scp execution lines to this:
$SshKey = "$ScriptDir/app-deploy-key" # private key
# Upload
scp -i "$SshKey" -r "$LocalWheelhousePath" "deploy@$LinuxIP:$RemoteProjectDir/"
scp -i "$SshKey" "$($WhlFile.FullName)" "deploy@$LinuxIP:$RemoteProjectDir/"
# Execute
ssh -i "$SshKey" "deploy@$LinuxIP" "bash $RemoteScript '$WhlName'"| Shell access | ❌ Disabled | | Arbitrary command execution | ❌ Prohibited | | File upload | ✅ Only to /root/workspace/app_controller | | Script execution | ✅ Only update_app.sh with valid .whl file | | Password requirement | ❌ No (Automatic) | | Main key security | ✅ Fully protected |
your-project/
├── build/
├── wheelhouse/
├── scripts/
│ └── install_script/
│ └── remote/
│ ├── Deploy-App.ps1
│ └── app-deploy-key ← ❌ Do not add to Git!
│ └── app-deploy-key.pub ← ✅ Can be in Git (optional)
└── .gitignore
.gitignore content:
# Deploy keys (private)
scripts/install_script/remote/app-deploy-key- Never place the private key (app-deploy-key) in Git, email, or chat.
- If the key is leaked, remove it from authorized_keys and create a new key.
- This method can be used for multiple servers (with separate keys).