Creating the jenkins user

Once you have a VPS running, create a user called jenkins with sudo privileges:

root@ci:# adduser jenkinsroot@ci:# usermod -aG sudo jenkins

Then, to allow us to log into the server as the power-restricted user jenkins and not root, we must first add the public key of our development machine to /home/jenkins/.ssh/authorized_keys; the easiest way to do that is to copy the /root/.ssh/ directory and change its owner:

root@ci:# cp -R /root/.ssh/ /home/jenkins/root@ci:# chown -R jenkins:jenkins /home/jenkins/.ssh/

Then, disable password authentication and root login by editing /etc/ssh/sshd_config:

PermitRootLogin noPasswordAuthentication no

Reload the SSH daemon for the new settings to take effect:

root@ci:# systemctl ...

Get Building Enterprise JavaScript Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.