How to add node binaries to the chroot Print

  • 0

Problem Description

You would like to use node binaries in the SSH chroot, however the node command is not found

Problem Resolution

You could simply change the user's shell to the unrestricted bash shell, however if you don't wish to allow your clients that level of access to the server, that's understandable!

You should begin by taking a read over the Plesk documentation on how to customize the chroot environment. You'll need to have the first couple steps from that article done, with the update_chroot.sh utility ready to run.

Then you can run this to specifically add node binaries to the chroot (note: they take up about 50MB for each version):

if [ -d /opt/plesk/node/ ]; then
  rsync -avR /opt/plesk/node/ /var/www/vhosts/chroot/ > /dev/null 2>&1
fi

And this to be able to simply run 'node' without the full path (for Node version 9):

echo 'export PATH=/opt/plesk/node/9/bin:$PATH' >> /var/www/vhosts/chroot/.bash_profile

And now that we have our chroot ready to go, we need to apply it to the subscription for which you want node access:

./update_chroot.sh --apply <domain>

Enjoy node!


Was this answer helpful?

← Back