Accessing nodes with root user

In most cases, SSH access to nodes within your environment is intentionally scoped to an application-specific user to prevent accidental corruption of key container configuration.

We understand, however, that some users may occasionally need full root access to install certain packages that are not supported as part of the default stacks offered by MightyBox. 

NOTE: Making changes to your node via root access may void MightyBox’s commitment to supporting the impacted environment. This technique is for advanced users only, proceed with caution.

To enable root access on a container, import the following JPS YAML configuration to the node of your choice.

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
	

After installation, SSH into your node and run theĀ sudo sucommand to access the root user.