Production SSH Access
codante-io/codante-io-frontProvides guidance and utilities for securely accessing the Codante Frontend production server via SSH. Use this when you need to connect to the production server, run commands, check logs, manage pm2 processes, troubleshoot issues, or verify deployments.
SKILL.md
name: Production SSH Access description: Provides guidance and utilities for securely accessing the Codante Frontend production server via SSH. Use this when you need to connect to the production server, run commands, check logs, manage pm2 processes, troubleshoot issues, or verify deployments.
Production SSH Access Skill
Overview
This skill guides you through accessing and working with the Codante Frontend production server hosted on Digital Ocean.
Server Information
- Host: 216.238.103.47
- User: robertotcestari
- OS: Linux (Ubuntu/Debian)
- Web Server: nginx
- Application Server: pm2 (Node.js process manager) -
codante-io-frontprocess - Runtime: Node.js >= 20
- Application Root:
/var/www/codante-io-front - Deployment Method: rsync (direct, no release directories)
Quick Access
Connect to Production Server
ssh [email protected]
Common SSH Commands
Check pm2 status:
ssh [email protected] "pm2 status"
Check nginx configuration:
ssh [email protected] "sudo nginx -t"
List nginx sites:
ssh [email protected] "ls /etc/nginx/sites-enabled/"
Check service status:
ssh [email protected] "systemctl status nginx"
File Transfer
WARNING: do not transfer files - this is used only for emergency debugging. To change files in the production server, use the deployment pipeline.
Copy files from production to local:
scp [email protected]:/path/on/server /local/path
Copy files from local to production:
scp /local/path [email protected]:/path/on/server
Production Application Paths
- Application Root:
/var/www/codante-io-front - Source Code:
/var/www/codante-io-front/(direct rsync, no releases/) - Build Output:
/var/www/codante-io-front/dist/(production build) - Node Modules:
/var/www/codante-io-front/node_modules/ - pm2 Config:
/var/www/codante-io-front/pm2.config.jsor ecosystem.config.js - Public:
/var/www/codante-io-front/dist(served by nginx) - .env Config:
/var/www/codante-io-front/.env(if used)
Log Access in Production
pm2 Logs
View pm2 process logs (live):
# Follow codante-io-front logs in real-time
ssh [email protected] "pm2 logs codante-io-front"
# View last 100 lines
ssh [email protected] "pm2 logs codante-io-front --lines 100"
View pm2 error logs specifically:
ssh [email protected] "pm2 logs codante-io-front --err"
View pm2 output logs specifically:
ssh [email protected] "pm2 logs codante-io-front --out"
Get pm2 process details:
ssh [email protected] "pm2 info codante-io-front"
nginx Logs
nginx access logs:
# Real-time access logs
ssh [email protected] "tail -f /var/log/nginx/access.log"
# Site-specific access logs (if configured)
ssh [email protected] "tail -f /var/log/nginx/codante-io-front-access.log"
nginx error logs:
# Real-time error logs
ssh [email protected] "tail -f /var/log/nginx/error.log"
# Site-specific error logs
ssh [email protected] "tail -f /var/log/nginx/codante-io-front-error.log"
System Logs - nginx/pm2 Services
nginx service logs:
ssh [email protected] "journalctl -u nginx -n 100 -f"
pm2 service logs (if using systemd):
# If pm2 is managed by systemd
ssh [email protected] "journalctl -u pm2-robertotcestari -n 100 -f"
View All Logs in Directory
# List log files with sizes
ssh [email protected] "ls -lh /var/log/nginx/"
# Check application logs if using custom logging
ssh [email protected] "ls -lh /var/www/codante-io-front/logs/ 2>/dev/null || echo 'No custom logs directory'"
Search and Filter Logs
Find errors in nginx logs:
ssh [email protected] "grep 'error\|ERROR\|502\|503' /var/log/nginx/error.log | head -50"
Find 502/503 errors:
ssh [email protected] "grep '502\|503' /var/log/nginx/access.log | tail -20"
Find 4xx errors:
ssh [email protected] "grep '4[0-9][0-9]' /var/log/nginx/access.log | tail -20"
Monitor logs with filter:
ssh [email protected] "tail -f /var/log/nginx/error.log | grep -E 'error|502|503|upstream'"
Download Logs Locally
Copy nginx access log:
scp [email protected]:/var/log/nginx/access.log ./nginx-access-backup.log
Copy all nginx logs:
scp -r [email protected]:/var/log/nginx/ ./nginx-logs/
Copy pm2 logs:
# pm2 logs are stored in ~/.pm2/logs/
scp -r [email protected]:~/.pm2/logs/ ./pm2-logs/
pm2 Management
Codante Frontend uses pm2 (Node.js process manager) running the codante-io-front process.
Check pm2 Status
# View all processes
ssh [email protected] "pm2 status"
# Get detailed process info
ssh [email protected] "pm2 info codante-io-front"
# View process list with resource usage
ssh [email protected] "pm2 monit"
View pm2 Logs
# Follow logs in real-time
ssh [email protected] "pm2 logs codante-io-front"
# View last N lines
ssh [email protected] "pm2 logs codante-io-front --lines 200"
# View error logs only
ssh [email protected] "pm2 logs codante-io-front --err"
Restart pm2 Process
# Restart the codante-io-front process
ssh [email protected] "pm2 restart codante-io-front"
# Reload (graceful restart - used for 0-downtime reloads)
ssh [email protected] "pm2 reload codante-io-front"
# Stop process
ssh [email protected] "pm2 stop codante-io-front"
# Start process
ssh [email protected] "pm2 start codante-io-front"
Monitor pm2 Process
# Monitor memory usage
ssh [email protected] "pm2 monit codante-io-front"
# Get process details including memory
ssh [email protected] "pm2 info codante-io-front"
# View real-time metrics
ssh [email protected] "watch 'pm2 status'"
View pm2 Config
# View ecosystem config if exists
ssh [email protected] "cat /var/www/codante-io-front/ecosystem.config.js 2>/dev/null || cat /var/www/codante-io-front/pm2.config.js 2>/dev/null || echo 'No pm2 config found'"
Common Production Tasks
Check Disk Space
ssh [email protected] "df -h"
Monitor CPU/Memory
ssh [email protected] "top -b -n 1 | head -20"
# Check specific process
ssh [email protected] "ps aux | grep 'node\|pm2'"
Restart Services
# Restart pm2 process
ssh [email protected] "pm2 restart codante-io-front"
# Restart nginx
ssh [email protected] "sudo systemctl restart nginx"
# Restart both
ssh [email protected] "pm2 restart codante-io-front && sudo systemctl restart nginx"
Check Current Deployment
# Check if app directory exists
ssh [email protected] "ls -la /var/www/codante-io-front/"
# Check git info
ssh [email protected] "cd /var/www/codante-io-front && git log -5 --oneline 2>/dev/null || echo 'Not a git repo'"
# Check if dist build exists
ssh [email protected] "ls -la /var/www/codante-io-front/dist/ | head -10"
# Check Node.js version
ssh [email protected] "node --version"
Deploy New Release
When deploying via GitHub Actions + rsync:
- Push to
mainbranch - GitHub Actions triggers automated deployment
- GitHub Actions handles:
- npm install
- Build production (npm run build)
- rsync to server at
/var/www/codante-io-front - pm2 restart (post-deploy)
Check deployment status:
ssh [email protected] "ls -lah /var/www/codante-io-front/ | head -20"
Verify Application is Running
# Check if pm2 process is running
ssh [email protected] "pm2 status | grep codante-io-front"
# Check if nginx is serving requests
ssh [email protected] "curl -I http://localhost:3000"
# Check nginx proxy to port 3000
ssh [email protected] "sudo netstat -tlnp | grep -E '3000|80|443'"
Clear Build Cache (if needed)
# Remove node_modules and dist
ssh [email protected] "cd /var/www/codante-io-front && rm -rf node_modules dist"
# Full rebuild on next deployment
ssh [email protected] "cd /var/www/codante-io-front && npm install && npm run build"
Security Considerations
- SSH Keys: Ensure your SSH key is added to
~/.ssh/authorized_keyson the server - sudo Access: Use
sudofor privileged commands (requires password or sudo setup) - Environment Variables: Never expose sensitive data in logs or console output
- Log Files: Check logs for errors, security warnings, and performance issues
- Backups: Always ensure backups exist before making changes to production
- Process State: pm2 maintains process state; changes to app code require rebuild and restart
- nginx Proxy: Verify nginx configuration before restarting to avoid service disruption
- Deployment: Use automated GitHub Actions pipeline instead of manual rsync when possible
Troubleshooting
Connection Issues
If you can't connect:
- Verify SSH key is configured:
ssh-keyscan 216.238.103.47 - Check your SSH config:
~/.ssh/config - Test connectivity:
ping 216.238.103.47
Permission Denied
If you get "Permission denied":
- Verify the username is
robertotcestari - Check SSH key permissions:
chmod 600 ~/.ssh/id_rsa - Ensure public key is on server:
cat ~/.ssh/id_rsa.pub
pm2 Process Not Running
If pm2 process is stopped:
- Check status:
pm2 status - View recent logs:
pm2 logs codante-io-front --lines 50 - Restart process:
pm2 restart codante-io-front - Verify app directory exists:
ls /var/www/codante-io-front/
Build Not Found
If npm run build output doesn't exist:
- Check if dist/ folder exists:
ls /var/www/codante-io-front/dist/ - Check package.json build script:
cat /var/www/codante-io-front/package.json | grep -A 5 '"build"' - Manually trigger build:
cd /var/www/codante-io-front && npm install && npm run build
nginx 502 Bad Gateway
If you see 502 errors in nginx:
- Check if pm2 process is running:
pm2 status - Check if Node app is listening on port 3000:
curl http://127.0.0.1:3000 - Check nginx error log:
tail -f /var/log/nginx/error.log - Restart pm2:
pm2 restart codante-io-front - Restart nginx:
sudo systemctl restart nginx
High Memory Usage
If Node process is consuming too much memory:
- Check memory:
ps aux | grep node - View pm2 memory usage:
pm2 info codante-io-front - Check logs for memory leaks:
pm2 logs codante-io-front - Restart process:
pm2 restart codante-io-front - Monitor memory:
pm2 monit
Slow Response Times
If application is slow:
- Check nginx access logs:
tail -f /var/log/nginx/access.log | grep "HTTP/\|response" - Check backend API availability:
curl -I http://127.0.0.1:8000 - Check CPU usage:
top -p $(pgrep -f 'node') - Monitor pm2:
pm2 monit - Check disk I/O:
iostat -x 1
Application Won't Start After Deployment
If app fails to start:
- Check deployment logs:
pm2 logs codante-io-front - Check if dependencies installed:
ls /var/www/codante-io-front/node_modules/ - Check for build errors:
cd /var/www/codante-io-front && npm run build - Verify .env file exists:
test -f /var/www/codante-io-front/.env && echo 'exists' || echo 'missing' - Check if API backend is reachable:
curl http://127.0.0.1:8000/health
When to Use This Skill
Use this skill when you need to:
- ✅ Connect to the production server
- ✅ Debug production issues
- ✅ Access and analyze production logs (pm2, nginx)
- ✅ Monitor real-time log streams
- ✅ Check server logs and metrics
- ✅ Manage pm2 processes
- ✅ Verify deployments
- ✅ Transfer files to/from production
- ✅ Run ad-hoc commands on production
- ✅ Troubleshoot deployment issues
- ✅ Monitor performance and resource usage
- ✅ Check backend API availability
- ✅ Verify nginx proxy configuration
Related Resources
- CLAUDE.md deployment section for CI/CD information
- Server management documentation
- GitHub Actions workflow (
.github/workflows/deploy.yml) - pm2 documentation: https://pm2.keymetrics.io/docs/usage/quick-start/
- React Router documentation: https://reactrouter.com/