Saturday, February 15, 2014

Execute SSH command as root from a Jenkins build without using keys

Here is an easy way to execute SSH commands on a Linux server from a Jenkins job without having to generate cumbersome keys. While this method may not be as secure as public key cryptography, if you are working in a securely firewalled private network (not the DMZ) that should be less of an issue.

Two plug-ins are used to make this work:
The EnvInject Plugin allows a job to setup environment variables, one of which can be used for masked passwords. I prefer this plugin to mask passwords as they do not show up in the build log or build environment variable saved information.
Assigning a masked password to the "sudopass" environment variable.

The Publish Over SSH plugins allows one to send files or execute commands over SSH as a build step. As you will see below there are three "Advanced" buttons, which are all open, you can select to see more options for this plugin. In the setup below it was necessary to check the "Exec in pty" box in order for the SSH command to run. (The SSH Server setup in the top part of the plugin must be done from the Jenkins Master configuration page.)

Exec command as root using SSH.

Here is SSH sudo command typed out:

echo $sudopass | sudo -S /local/apps/javahost/scripts/stopServer.sh || true

49 comments:

  1. Hi friends, This is Chandrika from Chennai. I did Unix certification course in Chennai at Fita academy. This is really useful for me to make a bright career. Suppose if anyone interested to learn Unix Course in Chennai please visit Fita academy located at Chennai.

    ReplyDelete
  2. Hi! I hate spam and spammers. Could someone remove the spam posting above this one? Thanks.

    ReplyDelete
  3. she has a bright career on sending spam messages. course failed.

    ReplyDelete
  4. Thanks for your post; marketing course is most trusted course to validate marketing. This course provides precise and complete information about a online marketing course.
    online marketing course in chennai

    ReplyDelete
  5. This post is very useful for us. Because we have a lot of
    tips and tricks from this post. Thank you for this amazing post share. I many
    tips about bd jobs as well. If you want to know more about a career sites, please visit our website.

    www.bd-career.com

    ReplyDelete
  6. There are lots of information about latest technology and how to get trained in them, like Best Hadoop Training In Chennai in Chennai have spread around the web, but this is a unique one according to me. The strategy you have updated here will make me to get trained in future technologies Hadoop Training in Chennai By the way you are running a great blog. Thanks for sharing this blogs..

    ReplyDelete
  7. I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing..
    SalesForce Training in Chennai

    ReplyDelete
  8. Pretty article! I found some useful information in your blog, it was awesome to read,thanks for sharing this great content to my vision, keep sharing..
    Unix Training In Chennai

    ReplyDelete
  9. This information is impressive..I am inspired with your post writing style & how continuously you describe this topic. After reading your post,thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic
    Android Training In Chennai In Chennai

    ReplyDelete
  10. SAP Training in Chennai
    This post is really nice and informative. The explanation given is really comprehensive and informative..

    ReplyDelete
  11. Oracle Training in chennai
    Thanks for sharing such a great information..Its really nice and informative..

    ReplyDelete
  12. Selenium Training in Chennai
    Wonderful blog.. Thanks for sharing informative blog.. its very useful to me..

    ReplyDelete
  13. Data warehousing Training in Chennai
    I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly..

    ReplyDelete
  14. Whatever we gathered information from the blogs, we should implement that in practically then only we can understand that exact thing clearly, but it’s no need to do it, because you have explained the concepts very well. It was crystal clear, keep sharing..
    Websphere Training in Chennai

    ReplyDelete
  15. Oracle DBA Training in Chennai
    Thanks for sharing this informative blog. I did Oracle DBA Certification in Greens Technology at Adyar. This is really useful for me to make a bright career..

    ReplyDelete
  16. This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic..
    Informatica Training in chennai | QTP Training in Chennai



    ReplyDelete
  17. Crazy Bulk Australia 100% Safe and Legal Steroids

    Crazy Bulk is 100% safe and legal alternate steroids available in market right now. With 100% success rate and excellent muscle building effects from day 1

    ReplyDelete
  18. I'am planning to join Oracle certified course. I want some expert advice whether i should go for it or not.
    oracle training in chennai|oracle training institutes in chennai|FITA Chennai

    complaints

    ReplyDelete
  19. Really awesome blog. Your blog is really useful for me.
    Thanks for sharing this informative blog. Keep update your blog.
    Oracle Training In Chennai

    ReplyDelete
  20. Best Java Training Institute In ChennaiThis information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic..

    ReplyDelete
  21. Thank you for this great tutorial. It was really helpful.

    jewelry photo editing services

    ReplyDelete
  22. Thank goodness someone is promoting quality content. I often struggle with myself.After refer that post more new information are get.
    hadoop

    ReplyDelete
  23. thanks for sharing about useful information and its more impressive.keep sharing.
    Informatica Training in Chennai

    ReplyDelete
  24. I read your articles very excellent and the i agree our all points because all is very good information provided this through in the post. It is very helpful for me. Keep blogging like this. Thanks.


    SAP training in Chennai

    ReplyDelete
  25. Thank you for sharing the nice information here. It will be useful for many people. So post like this relevant topics are welcome through this blog.

    Digital Marketing Training

    ReplyDelete


  26. These provided information was really so nice,thanks for giving that post and the more skills to develop after refer that post.our giving articles really impressed for me,because of all information so nice.

    SAP ABAP training in Chennai

    ReplyDelete
  27. Its really impressive post amazing content thanks for sharing info plugin wordpress

    ReplyDelete
  28. I feel happy about and I love learning more about this topic. keep sharing your information regularly for my future reference. This content creates a new hope and inspiration with in me. Thanks for sharing article like this.

    informatica training in Mylapore

    ReplyDelete



  29. yours idea is really good and innovative , these resources are really awesome thanks for sharing those information and i got more in formation about this concept.

    informatica training in chennai

    ReplyDelete
  30. What a great idea its all about website development look here and get now Buzz App

    ReplyDelete
  31. Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care and we take your comments to heart.As always, we appreciate your confidence and trust in us.

    SAP training in Chennai

    ReplyDelete
  32. It's interesting that many of the bloggers your tips helped to clarify a few things for me as well as giving.. very specific niche content. And tell people specific ways to live their lives.

    SQL DBA Training in Chennai

    ReplyDelete
  33. Great! Thanks for sharing the information. That is very helpful for increasing my knowledge in this fiel
    Red Ball | | duck life | Slitherio
    Red Ball 2 | Red Ball 3 | Red Ball 4

    ReplyDelete
  34. This idea is mind blowing. I think everyone should know such information like you have described on this post. Thank you for sharing this explanation.Your final conclusion was good. We are sowing seeds and need to be patiently wait till it blossoms.

    J2ee Training in Chennai Adyar

    ReplyDelete
  35. That is very interesting; you are a very skilled blogger. I have shared your website in my social networks!

    SAP Training in Chennai

    ReplyDelete
  36. You shared useful post. keep sharing such a useful post.

    digital marketing institute

    ReplyDelete
  37. Wonderful post. Glad to find your blog. Keep sharing.

    website design training in chennai

    ReplyDelete
  38. Wonderful post. Glad to find your blog. Keep sharing.....
    linux training in chennai

    ReplyDelete
  39. Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care and we take your comments to heart.As always, we appreciate your confidence and trust in us.

    Best Laser Clinic In Chennai

    Best Implant Clinic In Chennai

    ReplyDelete
  40. It's interesting that many of the bloggers your tips helped to clarify a few things for me as well as giving.. very specific nice content. And tell people specific ways to live their lives.Sometimes you just have to yell at people and give them a good shake to get your point across.

    SEO Company in India

    ReplyDelete
  41. This is extremely helpful info!! Very good work. It is very interesting to learn and easy to understood. Thank you for giving information. Please let us know and more information get post to link.

    Digital Marketing Company in Chennai

    ReplyDelete
  42. Your thinking toward the respective issue is awesome also the idea behind the blog is very interesting which would bring a new evolution in respective field. Thanks for sharing.

    SEO Company in India

    ReplyDelete


  43. Really nice information you had posted. Its very informative and definitely it will be useful for many people
    iOS Training in Chennai
    Android Training in Chennai
    php Training in Chennai

    ReplyDelete
  44. What you have written in this post is exactly what I have experience when I first started my blog.I’m happy that I came across with your site this article is on point,thanks again and have a great day.Keep update more information.

    Painless Dental Treatment In Chennai

    Best Dental Clinic In Adyar

    ReplyDelete
  45. It is really a great and useful piece of info. I’m glad that you shared this helpful info with us. Please keep us informed like this. Thank you for sharing.

    Dataware Housing Training in Chennai

    ReplyDelete