All Collections
Jelastic
SSH
How to gain root access
How to gain root access
Updated over a week ago

In this article, we will guide you on how to gain access as a route user.

Important!: By default, the root access is disabled.

1- Log in to the dashboard and click on IMPORT:

1-Dashboard-import.png

2- Go to JPS as below:

2-Import-JPS.png

3- Import this script:

{
  "jpsVersion": "0.3",
  "jpsType": "update",
  "application": {
    "categories": [
      "apps/dev-tools"
    ],
    "targetNodes": {
      "nodeGroup": [
        "cp",
        "nosqldb",
        "sqldb",
        "bl",
        "apache"
      ]
    },
    "name": "Root Access",
    "logo": "http://blog.jelastic.com/wp-content/uploads/2015/11/cs-scheme1.png",
    "version": "1.0",
    "homepage": "http://docs.jelastic.com",
    "description": {
      "short": "Root Access",
      "en": "Proceed with caution! Incorrect actions with root access may lead to your application or/and container malfunction!",
      "ru": "Bulletproof monitoring out of the box + endless ways to customize."
    },
    "short": {
      "en": "Root access"
    },
    "env": {
      "onInit": {
        "call": [
          {
            "procedure": "InstallRoot",
            "params": {
              "nodeGroup": "cp"
            }
          },
          {
            "procedure": "InstallRootSQLdb",
            "params": {
              "nodeGroup": "sqldb"
            }
          },
          {
            "procedure": "InstallRootNoSQLdb",
            "params": {
              "nodeGroup": "nosqldb"
            }
          },
          {
            "procedure": "InstallRootBL",
            "params": {
              "nodeGroup": "bl"
            }
          }
        ]
      }
    },
    "procedures": [
      {
        "id": "InstallRoot",
        "onCall": [
          {
            "executeShellCommands": [
              {
                "nodeGroup": "cp",
                "commands": [
                  "sed -i \"\\$aapache\\ ALL=NOPASSWD\\:\\ ALL\" /etc/sudoers",
                  "sed -i \"\\$atomcat\\ ALL=NOPASSWD\\:\\ ALL\" /etc/sudoers",
                  "sed -i \"\\$anginx\\ ALL=NOPASSWD\\:\\ ALL\" /etc/sudoers",
                  "sed -i \"\\$ajelastic\\ ALL=NOPASSWD\\:\\ ALL\" /etc/sudoers",
                  "sed -i \"\\$alitespeed\\ ALL=NOPASSWD\\:\\ ALL\" /etc/sudoers",
                  "sed -i \"\\$anodejs\\ ALL=NOPASSWD\\:\\ ALL\" /etc/sudoers"
                ],
                "user": "root"
              }
            ]
          }
        ]
      },
      {
        "id": "InstallRootSQLdb",
        "onCall": [
          {
            "executeShellCommands": [
              {
                "nodeGroup": "sqldb",
                "user": "root",
                "commands": [
                  "sed -i \"\\$amysql\\ ALL=NOPASSWD\\:\\ ALL\" /etc/sudoers",
                  "sed -i \"\\$apostgres\\ ALL=NOPASSWD\\:\\ ALL\" /etc/sudoers",
                  "sed -i \"\\$ajelastic\\ ALL=NOPASSWD\\:\\ ALL\" /etc/sudoers"
                ]
              }
            ]
          }
        ]
      },
      {
        "id": "InstallRootNoSQLdb",
        "onCall": [
          {
            "executeShellCommands": [
              {
                "nodeGroup": "nosqldb",
                "user": "root",
                "commands": [
                  "sed -i \"\\$amongod\\ ALL=NOPASSWD\\:\\ ALL\" /etc/sudoers",
                  "sed -i \"\\$ajelastic\\ ALL=NOPASSWD\\:\\ ALL\" /etc/sudoers"
                ]
              }
            ]
          }
        ]
      },
      {
        "id": "InstallRootBL",
        "onCall": [
          {
            "executeShellCommands": [
              {
                "nodeGroup": "bl",
                "user": "root",
                "commands": [
                  "sed -i \"\\$anginx\\ ALL=NOPASSWD\\:\\ ALL\" /etc/sudoers",
                  "sed -i \"\\$ajelastic\\ ALL=NOPASSWD\\:\\ ALL\" /etc/sudoers",
                  "sed -i \"\\$alitespeed\\ ALL=NOPASSWD\\:\\ ALL\" /etc/sudoers",
                  "sed -i \"\\$ahaproxy\\ ALL=NOPASSWD\\:\\ ALL\" /etc/sudoers"
                ]
              }
            ]
          }
        ]
      }
    ],
    "success": {
      "text": "WARNING! In case something breaks inside the container due to incorrect actions, Jelastic personell are not responsible for this! To get root access please connect to container via SSH and execute command sudo su",
      "email": false
    }
  }
}

As shown below:

3-JPS-script.png

4- Click IMPORT.
โ€‹
5- Choose the node from the drop-down menu:

4-Choose-the_node.png

6- Click INSTALL:

5-Install.png

7- Access the Server via SSH or Web SSH (in that documentation we will show the Web SSH and execute the command below:

$ sudo su -

You are all set!

Did this answer your question?