Knowledge base

1000 FAQs, 500 tutorials and instructional videos. Here, there are only solutions!

Manage Root Access on Jelastic Cloud (to run commands on any container)

This guide details the root access to Jelastic Cloud to run commands on any of your containers.

 

Preamble

  • Some Jelastic Cloud containers do not have root access by default.
  • It is possible to open this access on the containers of your choice via the installation of an add-on.
  • Also refer to this other guide if you are looking for information about installing packages without root access.

 

Authorize root access

To do this:

  1. Log in to the dashboard of your Jelastic Cloud.
  2. Click on the Import button from the top menu bar.
  3. Go to the JPS tab.
  4. Copy the following code and paste it into the JPS tab: 

    type: update
    name: Root Access
    targetNodes:
      nodeGroup: '*'
          
    onInstall:
      - cmd[${targetNodes.nodeGroup}]: |-
          TARGET_UID=$(id -u jelastic 2>/dev/null) || TARGET_UID="700"
          getent passwd "${TARGET_UID}" &>/dev/null && TARGET_USER=$(getent passwd "${TARGET_UID}" | cut -d: -f1)  || TARGET_USER="jelastic"
          sed -i "\$a${TARGET_USER}\ ALL=NOPASSWD\:\ ALL" /etc/sudoers; echo ${TARGET_USER}
        user: root
      - setGlobals:
          sudo_user: ${response.out}
    onUninstall:
      cmd[${targetNodes.nodeGroup}]: |-
          sed -i "/${globals.sudo_user}\ ALL=NOPASSWD\:\ ALL/d" /etc/sudoers
      user: root
  5. Click on the Import button.
  6. Choose the environment and the node on which root access is required.
  7. Click on the Install button.

To then run commands as root, connect to your application via SSH and enter the command sudo su.


Has this FAQ been helpful?