Sonatype Nexus is extraordinary compared to other store administrators out there. It is some apparatus that you can’t maintain a strategic distance from in your CI/CD pipeline. It adequately oversees deployable ancient rarities.
This post guides you to introduce and arrange Sonatype Nexus 3 of every a safe route on ubutnu machine.
Step 1: Update the System
You need to update the current Ubuntu’s repository with given command.
sudo apt-get update
Step 2: Install Dependencies
Nexus is running on JAVA So that’s why you need to install first JAVA with given commands.
sudo apt-get install default-jdk -y
Step 3: Download Nexus
After this, You need to download the nexus tarball from the sonatype download link with following the commands, You can get the latest download links for nexus from here.
cd /opt/ && sudo wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz
Step 4: Extract the Nexus
sudo tar -xzvf latest-unix.tar.gz
Rename the Nexus directory to nexus by following the command.
sudo mv /opt/nexus-* /opt/nexus
Step 5: Add Nexus User
As a decent security practice, it isn’t encouraged to run nexus administration with any sudo client. So make another client named nexus.
sudo useradd nexus
Here you need to allow nexus user to password less by editing the sudo file.
sudo visudo
Add the following lines and save end exit from the editor.
nexus ALL=(ALL) NOPASSWD: ALL
Step 6: Update the Permission
You need to update the permission with nexus user by following the commands.
sudo chown -R nexus:nexus /opt/nexus
sudo chown -R nexus:nexus /opt/sonatype-work
Step 7: Add nexus as a service at boot time
Open and add the nexus user in /opt/nexus/bin/nexus.rc configuration file and uncomment the run_as_user parameter as given below.
sudo vim /opt/nexus/bin/nexus.rc
run_as_user="nexus"
Configure nexus service by using the following commands.
sudo ln -s /opt/nexus/bin/nexus /etc/init.d/nexus
Step 8: Start the Nexus Services
You need to login as nexus user and execute the following commands for start the nexus services.
su - nexus
/etc/init.d/nexus start
Step 9: Verify the Ports
You can use the netstat cli to get Nexus port, Use the following command for that, if you do not able to find the port 8081 so then try after 5 mins to check port 8081 using telnet.
sudo netstat -plntu | grep 8081
You need to add the inbound rules in UFW firewall, Use the following command for that.
sudo ufw allow 8081
Step 11: Access the Nexus Web Panel
You need to the given URL to access the Nexus Web Panel and use the provided credential to login nexus admin panel.
http://localhost:8081 or http://ip_address:8081
You should get the nexus web page to login in dashboard, Now you need to set the admin password by using the given steps, By defaults username is admin and to get password you need to use the following command.
cat /opt/sonatype-work/nexus3/admin.password
Now update the password for admin account.