DevOps: Jenkins & AWS Series, Part 1- How to Install Jenkins on AWS Ubuntu 22.04
Introduction:
Jenkins is an open-source automation server that helps to automate various stages of software development. It is primarily used for Continuous Integration and Continuous Delivery/Deployment (CI/CD) pipelines, which allow developers to quickly build, test, and deploy their code to production.
AWS (Amazon Web Services) is a cloud computing platform that provides a range of services for developers and businesses to build and deploy applications on the cloud. AWS has a wide range of services, including computing, storage, database, networking, and machine learning.
A step-by-step guide to installing Jenkins on an AWS EC2 Ubuntu 22.04 instance:
Launch an EC2 instance: First, launch an EC2 instance on AWS with Ubuntu 22.04 as the operating system. You can select the appropriate instance type based on the requirements of your project.
Connect to the instance: Once the instance is launched, connect to it using SSH. You can use the SSH client of your choice (e.g., Browser, PuTTY on Windows, Terminal on Mac/Linux).
For more details or “All in one” command, you can click on the GitHub link:
Install Java: Jenkins requires Java to run, so the first step is to install Java on the Ubuntu instance. You can do this by running the following command:
sudo apt-get update
sudo apt-get install openjdk-11-jdk
Add Jenkins repository: Next, you need to add the Jenkins repository to the instance by running the following commands:
sudo curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null
sudo echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null
Install Jenkins: Now you can install Jenkins by running the following command:
sudo apt-get update
sudo apt-get install jenkins
Start Jenkins: Once Jenkins is installed, start & enable the Jenkins service using the following command:
sudo systemctl start jenkins
sudo systemctl status jenkins
sudo systemctl enable jenkins
Configure Jenkins: Finally, you can configure Jenkins by accessing the Jenkins web interface using the public IP address of your EC2 instance and the default port 8080 (e.g., http://<EC2_Public_IP>:8080).
Follow the on-screen instructions to complete the Jenkins setup wizard. You will be prompted to enter the initial admin password, which you can find in the file /var/lib/jenkins/secrets/initialAdminPassword
.
Once the setup wizard is complete, Jenkins is ready to use!
That’s it! You should now have Jenkins installed and running on your AWS EC2 Ubuntu 22.04 instance, and you can start using it to automate your software development processes.
Jenkins 2.397 and 2.387.2: New Linux Repository Signing Keys
Beginning March 28, 2023, the Jenkins weekly releases will use new repository signing keys for the Linux installation packages. The same change will be made in Jenkins LTS releases beginning April 5, 2023. Administrators of Linux systems must install the new signing keys on their Linux servers before installing Jenkins Jenkins weekly 2.397 or Jenkins LTS 2.387.2.
A common error:
If found any error related to the security certificate in keys, please update your commands with “jenkins.io-2023.key”
W: GPG error: https://pkg.jenkins.io/debian-stable binary/ Release: The following signatures couldn’t be verified because the public key
is not available: NO_PUBKEY FCEF32E745F2C3D5
E: The repository ‘https://pkg.jenkins.io/debian-stable binary/ Release’ is not signed.
N: Updating from such a repository can’t be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details”
You need to replace your old command with new commands as mentioned below:
sudo curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null
sudo echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null
Why is the repository signing key being updated?
The repository signing key expires after 3 years so that it matches the expiration dates of the jar file signing and the MSI signing certificate. The updated GPG repository signing key is used in the weekly repositories and the stable repositories.
When installing Jenkins on an AWS EC2 Ubuntu 22.04 instance, it is important to add the Jenkins repository signing key to the system in order to ensure the authenticity of the Jenkins package being installed. This can be done by running the command
sudo curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null
By following best practices such as adding repository signing keys, you can enhance the security of your system and minimize the risk of malware or other security threats compromising your software development processes.
Conclusion:
In conclusion, adding repository signing keys to the Linux installation packages is a crucial security measure that ensures the authenticity and integrity of the packages being installed on your system. By verifying the signature of the package using the repository signing key, you can be sure that the package has not been tampered with or modified in any way.
For more info please connect & Follow me:
Github: https://github.com/manikcloud
LinkedIn: https://www.linkedin.com/in/vkmanik/
Email: varunmanik1@gmail.com
Facebook: https://www.facebook.com/cloudvirtualization/
YouTube: https://bit.ly/32fknRN
Twitter: https://twitter.com/varunkmanik