> ## Documentation Index
> Fetch the complete documentation index at: https://docs.doploy.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect via SSH

> Connect to your server via SSH using Termius or terminal

## Overview

Connect to your doploy server via SSH for advanced server management, debugging, and direct access to your Odoo containers.

**Note:** SSH access is available for production and staging servers. Development builds run on shared infrastructure and don't support direct SSH access.

## Prerequisites

* A doploy server (doploy-managed or BYOS)
* SSH client (Termius, Terminal, or PuTTY)
* Your SSH key pair (public and private keys)

## Step 1: Generate SSH Key Pair

### Using Termius (Recommended)

1. Open Termius
2. Go to **Keychain** → **Keys**
3. Click the **+** button to create a new key
4. Select **Generate new key**
5. Enter a name for your key (e.g., "doploy-server")
6. Choose key type: **RSA** (recommended)
7. Click **Generate**
8. Select the key and copy the Public key value

### Using Terminal (Mac/Linux)

```bash theme={null}
# Generate a new SSH key pair
ssh-keygen -t rsa -b 4096 -C "your-email@example.com"

# Save to default location (~/.ssh/id_rsa) or specify a custom path
# Example: ~/.ssh/doploy_key

# Display your public key
cat ~/.ssh/id_rsa.pub
```

Copy the entire public key output (starts with `ssh-rsa`).

### Using PuTTYgen (Windows)

1. Download and open **PuTTYgen**
2. Click **Generate**
3. Move your mouse randomly to generate entropy
4. Add a key comment (e.g., "doploy-server")
5. Click **Save private key** (save as `.ppk` file)
6. Copy the public key from the text box at the top

## Step 2: Add SSH Key to doploy Server

### Access Servers Page

From your project dashboard, navigate to the **Servers** page.

### Add Your Public Key

1. Find the server you want to access
2. Click the **Add SSH Key** button
3. Paste your **public key** into the text area
4. Click **Add SSH Key**

Your public key will be added to the server's `~/.ssh/authorized_keys` file.

## Step 3: Connect to Your Server

### Get Server Connection Details

On the Servers page, note your server's:

* **IP Address** (shown on the server card)
* **Username** (default: `ubuntu` for doploy servers, or your custom username for BYOS)
* **Port** (default: `22`)

### Using Termius

1. Open Termius
2. Click **+** → **New Host**
3. Enter connection details:
   * **Alias**: A friendly name (e.g., "doploy Production")
   * **Hostname**: Your server's IP address
   * **Port**: 22
   * **Username**: `ubuntu` (or your custom username)
4. Under **Keys**, select the SSH key you created earlier
5. Click **Save**
6. Double-click the host to connect

### Using Terminal (Mac/Linux)

```bash theme={null}
# Connect using your private key
ssh -i ~/.ssh/id_rsa ubuntu@YOUR_SERVER_IP

# Or if you used a custom key path
ssh -i ~/.ssh/doploy_key ubuntu@YOUR_SERVER_IP
```

**Optional:** Add to your SSH config for easier access:

```bash theme={null}
# Edit SSH config
nano ~/.ssh/config

# Add this configuration
Host doploy-prod
    HostName YOUR_SERVER_IP
    User ubuntu
    IdentityFile ~/.ssh/id_rsa
    Port 22
```

Then connect with:

```bash theme={null}
ssh doploy-prod
```

### Using PuTTY (Windows)

1. Open **PuTTY**
2. Enter **Host Name**: Your server's IP address
3. **Port**: 22
4. **Connection type**: SSH
5. In the left sidebar, go to **Connection** → **SSH** → **Auth**
6. Click **Browse** and select your private key (`.ppk` file)
7. Return to **Session**, enter a name under **Saved Sessions**, and click **Save**
8. Click **Open** to connect

## Common SSH Tasks

Once connected, you can perform various server management tasks:

### View Running Containers

```bash theme={null}
# List all running Odoo containers
docker ps

# View logs for a specific container
docker logs CONTAINER_NAME

# Follow logs in real-time
docker logs -f CONTAINER_NAME
```

### Access Odoo Container Shell

```bash theme={null}
# Access a running Odoo container
docker exec -it CONTAINER_NAME bash

# Once inside the container, you can run Odoo commands
odoo-bin shell
```

### Check Server Resources

```bash theme={null}
# Check disk usage
df -h

# Check memory usage
free -h

# Check CPU usage
top
```

## Security Best Practices

**Protect your private key** - Never share your private key.

**Use strong passphrases** - When generating keys, use a strong passphrase to encrypt your private key.

**Limit key access** - Set proper permissions on your private key file:

```bash theme={null}
chmod 600 ~/.ssh/id_rsa
```

**Rotate keys regularly** - Generate new keys periodically and remove old ones from servers.

**Use separate keys** - Consider using different SSH keys for different projects or environments.

## Troubleshooting

### Permission Denied (publickey)

* Verify you added the correct **public key** to the server
* Ensure you're using the matching **private key** to connect
* Check that your private key has correct permissions (`chmod 600`)

### Connection Timeout

* Verify the server IP address is correct
* Check that the server is running (status should be "Ready")
* Ensure your firewall allows outbound SSH connections on port 22

Then try connecting again.

### Wrong Username

* For doploy-managed servers, use `root`
* For BYOS servers, use the username you specified during server setup

## Need Help?

If you're having trouble connecting via SSH, contact doploy support with:

* Your server IP address
* The error message you're seeing
* The SSH client you're using

## Next Steps

* [Reset admin password](/managing-odoo/reset-admin-password)
* [Remote database access](/managing-odoo/remote-database-access)
* [View server metrics](/servers/doploy-servers)
