API Authentication and API Keys

Server Scout uses two distinct authentication methods to secure access to its API endpoints: session-based authentication for interactive use and API key authentication for programmatic access and agent communication.

Authentication Methods

Session-Based Authentication

The dashboard web interface uses session-based authentication with secure cookies. When you log in through your browser at app.serverscout.ie, the system creates an encrypted session and returns an HttpOnly cookie that your browser automatically includes in subsequent requests.

This method is ideal for building custom tools that interact with the same endpoints as the dashboard. To authenticate programmatically:

  1. Send your login credentials to the authentication endpoint
  2. Capture the returned session cookie
  3. Include this cookie in subsequent API requests

Session cookies expire automatically and cannot be used outside of HTTPS connections.

API Key Authentication

API keys provide a secure method for agents and automated systems to authenticate with Server Scout's API. Each server receives a unique 64-character hexadecimal key during the setup process.

API keys are sent via the X-API-Key HTTP header with every request:

X-API-Key: a1b2c3d4e5f6789012345678901234567890abcdef1234567890abcdef123456

This authentication method is stateless and doesn't require managing sessions or cookies, making it perfect for the lightweight Scout agent and other automated tools.

How API Keys Work

When you add a new server to Server Scout, the system automatically generates a unique API key for that server. This key serves as both identification and authentication—it tells the API which server is sending data and proves that the request is authorised.

The Scout agent stores this key locally and includes it in every data transmission. The 64-character hexadecimal format provides excellent entropy whilst remaining easily manageable by scripts and configuration files.

All API communication, regardless of authentication method, must use HTTPS to ensure keys and session data remain encrypted in transit.

API Key Security Best Practices

Treat API keys with the same security considerations as passwords:

  • Never commit keys to version control systems like Git repositories
  • Avoid sharing keys in plain text via email, chat, or documentation
  • Use environment variables or secure configuration files when building custom integrations
  • Implement proper access controls on systems that store API keys
  • Monitor key usage through Server Scout's activity logs

If you suspect a key has been compromised, rotate it immediately through the dashboard.

Key Rotation

Server Scout allows you to regenerate API keys when needed. This process immediately invalidates the old key and creates a new one:

  1. Navigate to your server's settings in the dashboard
  2. Click "Regenerate API Key"
  3. Copy the new key
  4. Update your agent configuration
  5. Restart the Scout agent

Important: The old key becomes invalid immediately upon regeneration. Ensure you update the agent configuration promptly to avoid monitoring interruptions.

Key Storage Location

The Scout agent stores its API key in the configuration file located at:

/opt/scout-agent/agent.env

This file contains environment variables used by the agent, including the SCOUTAPIKEY variable. The file permissions are set to restrict access to the root user only, providing an additional security layer.

When rotating keys, you'll need to update this file with the new key value and restart the agent service.

Building Custom Integrations

If you're developing custom tools that interact with Server Scout's API, choose the authentication method that best fits your use case:

  • Use session authentication for interactive tools where users log in with their credentials
  • Use API key authentication for automated scripts, monitoring tools, or server-to-server communication

Both methods provide secure access to the same underlying API endpoints, ensuring your custom integrations can leverage Server Scout's full monitoring capabilities whilst maintaining robust security standards.

Frequently Asked Questions

How do I authenticate with ServerScout API

ServerScout offers two authentication methods: session-based authentication for interactive use (using secure cookies from the dashboard login) and API key authentication for programmatic access. API keys are sent via the X-API-Key HTTP header, while session authentication uses encrypted cookies from logging into app.serverscout.ie.

Where is my ServerScout API key stored

The Scout agent stores its API key in the configuration file at /opt/scout-agent/agent.env under the SCOUT_API_KEY variable. This file has restricted permissions allowing only root user access for security. When you rotate keys, you'll need to update this file and restart the agent service.

How does ServerScout API key authentication work

When you add a new server, ServerScout automatically generates a unique 64-character hexadecimal API key. This key serves dual purposes: identifying which server is sending data and proving the request is authorized. The Scout agent includes this key in every data transmission via the X-API-Key HTTP header.

How to rotate ServerScout API key

Navigate to your server's settings in the dashboard and click 'Regenerate API Key'. Copy the new key, update your agent configuration file at /opt/scout-agent/agent.env, and restart the Scout agent. The old key becomes invalid immediately upon regeneration, so update promptly to avoid monitoring interruptions.

What happens if my API key is compromised

If you suspect your API key has been compromised, rotate it immediately through the dashboard. Go to server settings, regenerate the key, update the agent configuration, and restart the service. The old key is invalidated instantly, preventing unauthorized access while maintaining your monitoring capabilities.

ServerScout API key vs session authentication differences

API key authentication is stateless and perfect for automated tools and agents, using a 64-character hex key in HTTP headers. Session authentication uses encrypted cookies from dashboard login, ideal for interactive tools. Both provide access to the same API endpoints but serve different use cases.

ServerScout API key security best practices

Never commit API keys to version control systems like Git, avoid sharing keys in plain text via email or chat, use environment variables or secure configuration files for integrations, implement proper access controls on systems storing keys, and monitor key usage through ServerScout's activity logs.

Can I use ServerScout API without HTTPS

No, all ServerScout API communication must use HTTPS regardless of authentication method. This ensures API keys and session data remain encrypted in transit. Session cookies cannot be used outside HTTPS connections, and API key authentication also requires secure connections for proper security.

Was this article helpful?