SSH shell
Connect to SSH sessions of your Andasy applications for interactive terminal access and command execution
andasy ssh shell
The andasy ssh shell command establishes a secure SSH connection to your deployed Andasy application, providing direct terminal access for debugging, maintenance, and administrative tasks.
Overview
This command enables you to:
- Open interactive shell sessions within your application's runtime environment
- Execute commands directly on your app's container or virtual machine
- Debug issues in real-time with full terminal capabilities
- Perform administrative tasks without redeploying your application
Syntax
andasy ssh shell -a <app-name> [flags]
Aliases
You can use shorter versions of this command:
shellsh
Example using alias:
andasy ssh sh -a my-app
Initiating an SSH Session
To initiate an SSH session to a machine running your application, run:
andasy ssh shell -a <app-name>
Replace <app-name> with the name of your application. If you're currently in the root directory of the application, you can omit the -a flag as long as a andasy.hcl file exists in the root directory.
This command establishes an SSH connection to one of the machines running your application and opens an interactive shell session. You can then run commands as if you were logged into the machine directly.
Running a Single Command
Instead of opening an interactive session, you can execute a single command and exit:
andasy ssh shell -a <app-name> -c "ps aux | grep node"
This is useful for quick checks or when scripting automated tasks.
Available Flags
| Flag | Description |
|---|---|
-a, --app | The name of the app (required unless andasy.hcl is present) |
-c, --command | Execute a single command instead of opening an interactive session. The command runs and the session exits immediately |
-h, --help | Show help for the command |
--pty | Allocate a pseudo-terminal for the SSH session (default: true). A PTY is needed for interactive programs like text editors or interactive shells |
Common Use Cases
Inspecting Running Processes
andasy ssh shell -a my-app -c "ps aux"
Checking Disk Usage
andasy ssh shell -a my-app -c "df -h"
Viewing Environment Variables
andasy ssh shell -a my-app -c "env | grep DB"
Accessing Database (PostgreSQL)
# SSH into the database service
andasy ssh shell -a my-db-app
# Then run psql
psql -U postgres -d postgres
Checking Application Logs
# View logs directly on the machine
andasy ssh shell -a my-app -c "tail -f /var/log/app.log"
Note: For most log viewing, andasy logs is more convenient than SSH.
Security Considerations
- SSH access is secured through Andasy's private network
- Only authenticated users with access to the application can SSH into machines
- SSH sessions are logged for security auditing
- Changes made via SSH are ephemeral if not persisted to volumes or configuration
Related Commands
andasy logs- View application logs (often easier than SSH)andasy proxy- Forward ports for local database accessandasy apps- Manage your applications
Tip: If you want more controls provided by SSH protocol, make a proxy to SSH server of your VM with andasy proxy (it listens on TCP port 22) and connect with an external SSH program.