Title: Securely Interacting with Jenkins via SSH: A Step-by-Step Guide
Aniket Purohit
Junior DevOps Engineer at xFusionCorp | ??DevOps ∞ and Cloud ?? Journey with @KodeKloud!
?? What You'll Learn:
In this post, we'll explore how to configure SSH access for a user in Jenkins, enabling secure interactions with the Jenkins server. We'll cover setting up a public SSH key, configuring the Jenkins SSH service, and executing commands over SSH. This guide is perfect for DevOps engineers looking to enhance their CI/CD pipeline security and efficiency.
?? Step 1: Assigning a Public SSH Key to a User
I assigned a public SSH key to a user named Mike, allowing him access to the Jenkins server. This setup enables Mike to perform actions based on his assigned role.
?? Step 2: Configuring the SSH Service in Jenkins
We've configured the SSH service in Jenkins to listen on a specific port. To determine the port being used, run the following command:
领英推荐
curl -Lv https://localhost:8085/login 2>&1 | grep -i 'x-ssh-endpoint'
This command helps us identify the SSH endpoint port, ensuring we can connect to the Jenkins server securely.
?? Step 3: Interacting with Jenkins over SSH
With the SSH port identified, Mike can now interact with Jenkins over SSH. Using Mike's credentials, run the following command:
ssh -i /home/mike/.ssh/jenkins_key -l mike -p 8022 jenkins-server help
Key options:
?? Step 4: Restarting Jenkins Safely from the CLI
Using the help command, find the built-in command to safely restart Jenkins from the CLI. This ensures that Jenkins is restarted without affecting ongoing operations or builds.
By following these steps, you can securely manage Jenkins operations via SSH, enhancing your CI/CD workflows.
Feel free to engage with this post by sharing your thoughts or any additional tips you have for working with Jenkins and SSH! #DevOps #Jenkins #CI/CD #SSH #Automation