This guide walks you through deploying the PostgreSQL SSH MCP server on a Linux server with HTTPS.
- A Linux server (Ubuntu 22.04/24.04 recommended) — AWS EC2, DigitalOcean, Linode, etc.
- A registered domain name
- Firewall allowing ports 22 (SSH), 80 (HTTP), and 443 (HTTPS)
- PostgreSQL database (RDS or self-hosted)
- Auth0 configured (complete ChatGPT Setup Guide Steps 3.1-3.6 first)
Create an A record pointing your domain to your server:
| Type | Name | Value |
|---|---|---|
| A | your-subdomain | Server Public IP |
Verify DNS propagation:
nslookup your-subdomain.example.comssh -i your-key.pem ubuntu@your-server-ipUpdate system packages:
sudo apt update && sudo apt upgrade -yInstall Node.js via nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
source ~/.bashrc
nvm install 22Install nginx and Certbot:
sudo apt install -y nginx
sudo apt install -y certbot python3-certbot-nginxCreate nginx configuration:
sudo vim /etc/nginx/sites-available/mcpAdd the following (replace your-subdomain.example.com with your domain):
server {
listen 80;
server_name your-subdomain.example.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}
}Enable the site and reload nginx:
sudo ln -s /etc/nginx/sites-available/mcp /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginxRun Certbot to obtain and configure SSL:
sudo certbot --nginx -d your-subdomain.example.comVerify auto-renewal is configured:
sudo certbot renew --dry-runCertbot automatically updates your nginx config with SSL settings.
Create app directory:
sudo mkdir -p /opt/mcp-server
sudo chown ubuntu:ubuntu /opt/mcp-serverClone and build:
cd /opt/mcp-server
git clone https://github.com/zlash65/postgresql-ssh-mcp.git
cd postgresql-ssh-mcp
npm install
npm run buildCreate environment file:
vim /opt/mcp-server/postgresql-ssh-mcp/.envAdd your configuration:
# Database
DATABASE_URI=postgresql://user:password@your-db-host:5432/your-database
DATABASE_SSL=false
READ_ONLY=true
# SSH Tunnel (optional - uncomment if database is behind bastion)
# SSH_ENABLED=true
# SSH_HOST=bastion.example.com
# SSH_USER=ubuntu
# SSH_PRIVATE_KEY_PATH=/home/ubuntu/.ssh/id_rsa
# Query Settings
QUERY_TIMEOUT=30000
MAX_ROWS=1000
# HTTP Server
MCP_HOST=0.0.0.0
MCP_SESSION_TTL_MINUTES=30
# Auth0
MCP_AUTH_MODE=oauth
AUTH0_DOMAIN=your-tenant.us.auth0.com
AUTH0_AUDIENCE=https://your-subdomain.example.com/mcpCreate service file:
sudo vim /etc/systemd/system/postgresql-ssh-mcp.serviceAdd the following (update Node.js path if different):
[Unit]
Description=PostgreSQL SSH MCP Server
After=network.target
[Service]
Type=simple
User=ubuntu
WorkingDirectory=/opt/mcp-server/postgresql-ssh-mcp
EnvironmentFile=/opt/mcp-server/postgresql-ssh-mcp/.env
Environment=PATH=/home/ubuntu/.nvm/versions/node/v22.21.1/bin:/usr/bin:/bin
ExecStart=/home/ubuntu/.nvm/versions/node/v22.21.1/bin/node /opt/mcp-server/postgresql-ssh-mcp/dist/http.js
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.targetNote: Check your Node.js path with
which nodeand update the service file accordingly.
Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable postgresql-ssh-mcp
sudo systemctl start postgresql-ssh-mcpCheck service status:
sudo systemctl status postgresql-ssh-mcpView logs:
sudo journalctl -u postgresql-ssh-mcp -fTest health endpoint:
curl https://your-subdomain.example.com/healthExpected response:
{
"status": "ok",
"timestamp": "2025-12-27T...",
"version": "1.x.x"
}| Command | Description |
|---|---|
sudo systemctl status postgresql-ssh-mcp |
Check service status |
sudo systemctl restart postgresql-ssh-mcp |
Restart service |
sudo systemctl stop postgresql-ssh-mcp |
Stop service |
sudo journalctl -u postgresql-ssh-mcp -f |
View live logs |
sudo journalctl -u postgresql-ssh-mcp --since "1 hour ago" |
View recent logs |
sudo nginx -t |
Test nginx config |
sudo systemctl reload nginx |
Reload nginx |
sudo certbot renew |
Renew SSL certificate |
- Connect ChatGPT — Complete Step 4 in the ChatGPT Setup Guide to add your MCP server
- Monitor — Set up monitoring for your server (e.g., UptimeRobot, Datadog)