Publish Over SSH: Publish Over SSH is one of the plugins used to execute a command over Remote Linux Systems. It's easy to configure and manage, gives us the easier way to run a command on a remote machine.
In this my blog - how to install this Plug-in and setup initial configuration.
Prerequisites:
- Jenkins instance admin access
- another Linux system with sudo access.
Step 1- Install Plug-in - To install Publish over SSH plugin follow the step below to finish the installation.
Log in to Jenkins System > Manage Jenkins > Manage Plugins
- Select available plug-in tab > type "Publish over SSH" in the search bar on your right upside.
- Over Next page, check to restart Jenkins when installation is complete.
After successful installation of plug-in login to Jenkins again.
Step 2- Generate the Private and Public key: In order to set up communication between Jenkins server and Linux server. We need to Private Key (Place at Jenkins server) and Public key (Place on Remote Linux server).
Let's generate both the keys, using ssh-keygen command to generate the keys.
- SSH your Linux Server - Login user have sudo access
- Create a new user (Jenkins_srv) : To create new user run the command below.
Once a user created successfully. Generate keys using the following command
- Key created successfully, let check keys using the command below.
- Now copy your Public keys to Authorized_key. run below command.
- Now check .ssh folder to varified authorized_keys available on Linux system:
Step 4- Setup Private Key on Jenkins Server:
Now, Login to Jenkins server and follow the below steps to complete setup private key configuration.
- Login to Jenkins server
- Manage Jenkins > Configure System
- Now go to option Publish Over SSH - and paste Private keys here.
Step 5- Grant Jenkins_svc user sudo access:
Sometimes, we need to execute some command as sudo user, let grant our user sudo accessing using by the command below.
- Login Linux System with user have sudo access and edit file /etc/sudoers
Your sudoers file should be like above screenshot. Save and exit from the file.
Step 6- Test setting by executing a command.
- In order to test plugin settings, let's set up a freestyle project.
- Now, Execute the job and check Job's output for details.
- Let's check Job's Output:
Now, you are able to execute the command to a remote Linux machine. All set go setup more job with other configuration.
Thank you! please leave your comment to make the blog better!
I am Here to Get Learn Good Stuff About DevOps, Thanks For Sharing
ReplyDeleteDevOps
Training
DevOps
Training institute in Ameerpet
DevOps
Training institute in Hyderabad
DevOps
Training Online
What to do if I have to send some file to linux server from slave agent not master (jenkins )?
ReplyDelete