Install the Ruby agent

Install the Ruby agent on your system.

Create account

Installing the Sqreen Ruby agent allows you to monitor the security of your application and block attacks in real-time. Installing Ruby in your Rails application takes less than a minute:

Standard Ruby application

In your application root directory, add the Sqreen gem to your Gemfile:

echo "gem 'sqreen', '>= 1.16'" >> Gemfile

Find your organization token by going to Account Settings > Tokens in your Sqreen dashboard, or ( Your token has the prefix org_.

To help Sqreen identify the application when you use an organization token, you also need to set a unique application name.

Then, in a terminal, use the following commands from your application root directory:

# Install the Sqreen gem from your application directory
bundle install

# Set the Sqreen token and the application name
cat > config/sqreen.yml <<EOF

Application tokens deprecated

Application tokens are unique to an application. Organization tokens are available throughout the organization your account belongs to.

While Sqreen will continue to support application tokens for backward compatibility in the short term, they are now deprecated, and we encourage you to convert your applications to use organization tokens as soon as possible.

Follow this how-to to migrate applications using an application token.

Install the agent on non production environments

Typically you install the Sqreen agent in your production environment, but you can create several applications by specifying the environment in the application name.

# Set the Sqreen token and the app name, including the environment
cat > config/sqreen.yml <<EOF
app_name: "foobar (production)"

Basic configuration

The Sqreen agent stores your configuration in the sqreen.yml file.

Instead of using the Sqreen configuration file, you can also use the SQREEN_TOKEN and SQREEN_APP_NAME environment variables to set up your token and the application name.


The Sqreen Ruby agent provides flexible configuration settings. Refer to Configuration of the Ruby agent for more detailed information.

Uninstall the agent

To uninstall the Sqreen agent, remove the sqreen gem from your Gemfile.


The Sqreen Ruby agent's gem is available in the rubygems repository.

Use different Sqreen applications for different environments

We recommend you to use different Sqreen applications on your different environments: production, staging and development.

Bundler app (Sinatra)

For bundler apps (Sinatra), use the standard installation instructions for the Ruby agent and require the Sqreen gem from your application code after Sinatra in the Gemfile:

require 'sinatra'
require 'sqreen'

Linux distributions with no C++11 compiler

Some specific environments lack a C++11 compliant compiler (GCC >= 4.8 or clang >= 3.5). For example:

  • Stripped down Docker containers
  • Old distributions, such as Ubuntu Precise

In the first case, install g++ or clang before running bundle install or gem install. You can remove the C++ compiler afterwards, but you must keep the C++ runtime library (usually libstdc++).

In the case of older distributions, you might need to install a newer compiler from separate package repositories.

Travis Precise

To install Sqreen on Travis Precise, you can install GCC 4.8 by adding the following to the .travis.yml file:

      - ubuntu-toolchain-r-test
      - g++-4.8
  - CXX=g++-4.8