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

85 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
    Replies
    1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training India . Nowadays Java has tons of job opportunities on various vertical industry.

      Delete
  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
  46. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
    Android Training in Chennai
    Ios Training in Chennai

    ReplyDelete

  47. These ways are very simple and very much useful, as a beginner level these helped me a lot thanks fore sharing these kinds of useful and knowledgeable information.
    Android App Development Company

    ReplyDelete
  48. I am exploring this subject as part of a report I need to do on possible careers I might choose. Thank you for your post it has valuable information on this topic.
    alexandria car service

    ReplyDelete
  49. These ways are very simple and very much useful, as a beginner level these helped me a lot thanks fore sharing these kinds of useful and knowledgeable information.
    iOS App Development Company
    iOS App Development Company

    ReplyDelete
  50. Nice it seems to be good post... It will get readers engagement on the article since readers engagement plays an vital role in every blog.. i am expecting more updated posts from your hands.
    Fitness SMS
    Fitness Text
    Salon SMS
    Salon Text
    Investor Relation SMS
    Investor Relation Text

    ReplyDelete
  51. Hearty Thanks for this! I think this is enjoyable and useful. If you have time in hand you can visit edubuzz.net and can get job result, job circular, HSC result, SSC result, JSC result, PSC result and admission result.
    You can also visit visit techtwitters.com and can get update news, gadget review and new gadget news.

    ReplyDelete
  52. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
    Android Training in Chennai
    Ios Training in Chennai

    ReplyDelete
  53. Interesting blog about execution ssh command which attracted me more.Spend a worthful time.keep updating more.
    SEO Company in India

    ReplyDelete
  54. great comments thanks keep comments thank you blog CEO@bollox cheers

    ReplyDelete
  55. Being new to the blogging world I feel like there is still so much to learn. Your tips helped to clarify a few things for me as well as giving..
    Sms marketing
    Text message marketing
    Fitness SMS

    ReplyDelete
  56. Good post and I like it very much. By the way, anybody try this increase app downloads? I do not how to use.

    ReplyDelete
  57. I wondered upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.
    PSD to Wordpress
    wordpress website development

    ReplyDelete
  58. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.

    Best Java Training Institute Chennai

    ReplyDelete
  59. Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp great deal more around this condition.

    Best RPA Training in Bangalore


    Best RPA Training in Chennai


    ReplyDelete
  60. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
    amazon-web-services-training-institute-in-chennai

    ReplyDelete
  61. Very interesting blog which helps me to get the in depth knowledge about the technology, Thanks for sharing such a nice blog..
    Good discussion.
    Six Sigma Training in Abu Dhabi
    Six Sigma Training in Dammam
    Six Sigma Training in Riyadh

    ReplyDelete
  62. Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us. Do check | Get trained by an expert who will enrich you with the latest updates.
    CCNA Training in Chennai
    DevOps Training in Chennai
    DevOps foundation certificate
    DevOps institute certification
    CCNA Training institute in Chennai
    CCNA institute in Chennai

    ReplyDelete
  63. Excellent post. I am really impressed the way you have written the article. I have gained some insight knowledge about the topic

    Linux Course in Chennai | Linux Training | Learn Linux | Linux Course in Adyar | Linux Course in Tambaram | Linux Course in Velachery

    ReplyDelete
  64. Nice tutorial. Thanks for sharing the valuable information. it’s really helpful. Who want to learn this blog most helpful. Keep sharing on updated tutorials…
    Java training in Chennai | Java training in USA |

    Java training in Bangalore | Java training in Indira nagar | Java training in Bangalore | Java training in Rajaji nagar

    ReplyDelete
  65. Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.
    Best Devops Training in pune | Java training in Pune

    ReplyDelete
  66. I am sure this post has helped me save many hours of browsing other related posts just to find what I was looking for. Many thanks!

    python training in chennai | python course institute in chennai | Data Science Interview questions and answers

    ReplyDelete
  67. Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.
    safety course in chennai

    ReplyDelete
  68. When I initially commented, I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get several emails with the same comment. Is there any way you can remove people from that service? Thanks.

    Advanced AWS Interview Questions And Answers

    Advanced AWS Training in Chennai | Best AWS Training in Chennai

    Advanced AWS Training in Pune | Best Amazon Web Services Training in Pune

    ReplyDelete
  69. Thanks for the informative article. This is one of the best resources I have found in quite some time. Nicely written and great info. I really cannot thank you enough for sharing.

    angularjs Training in bangalore

    angularjs Training in bangalore

    angularjs online Training

    angularjs Training in marathahalli

    angularjs interview questions and answers

    ReplyDelete
  70. Brilliant ideas that you have share with us.It is really help me lot and i hope it will help others also.update more different ideas with us.
    AWS Training in Amjikarai
    AWS Training in Thirumangalam
    AWS Web Services Training in Bangalore
    AWS Training center in Bangalore

    ReplyDelete