{"id":1268,"date":"2017-05-06T05:33:55","date_gmt":"2017-05-06T05:33:55","guid":{"rendered":"http:\/\/www.testingdocs.com\/questions\/?p=1268"},"modified":"2024-11-16T14:58:09","modified_gmt":"2024-11-16T14:58:09","slug":"what-is-jsch","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/what-is-jsch\/","title":{"rendered":"What is JSch?"},"content":{"rendered":"<h3>Introduction<\/h3>\n<p>JSch stands for Java Secure Shell. It allows you to connect to an ssh remote server. SSH stands for Secure Shell. It provides support for secure remote login, secure file transfer, etc. It can automatically encrypt, authenticate, and compress transmitted data.<\/p>\n<p>You can find more information about the JSch library at <a href=\"http:\/\/www.jcraft.com\/jsch\/\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/www.jcraft.com\/jsch\/<\/a><\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-801\" src=\"http:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/ssh-communication.png\" sizes=\"auto, (max-width: 901px) 100vw, 901px\" alt=\"ssh communication\" width=\"901\" height=\"476\" title=\"\"><\/p>\n<h2><\/h2>\n<p>We can use this library in Java automation and in automation frameworks where you need to connect , copy files to remote machines without manual intervention. Using this library you can also connect to cloud machines in a secure way automatically. You can easily integrate the JSch library into your automation code using Maven build tool.<\/p>\n<h3><strong>JSch Code Examples<\/strong><\/h3>\n<p>You can find some bunch of simple Java programs, which demonstrates various JSch Features. Here is the link where you can find them:<\/p>\n<p><a href=\"http:\/\/www.jcraft.com\/jsch\/examples\/\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/www.jcraft.com\/jsch\/examples\/ <\/a><\/p>\n<h3><strong>Maven Dependency<\/strong><\/h3>\n<p>In order to use the library in your automation, simply add this dependency to your existing pom.xml file. You may need to update your project after adding this to your project. JSch library is available on Maven central repository. In-case you need the latest library jar you can check the Central repository.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;dependency&gt;\r\n &lt;groupId&gt;com.jcraft&lt;\/groupId&gt;\r\n &lt;artifactId&gt;jsch&lt;\/artifactId&gt;\r\n &lt;version&gt;0.1.54&lt;\/version&gt;\r\n &lt;\/dependency&gt;\r\n<\/pre>\n<p>&nbsp;<\/p>\n<h3><strong>Usage<\/strong><\/h3>\n<p>You can instantiate and get a connection using <strong>JSch<\/strong> class as shown below. The <strong>Session<\/strong> object with username and host is required. The TCP port 22 will be used in making the connection. TCP connection will be established when you invoke session.connect().<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">JSch jsch = new JSch();\r\nsession = jsch.getSession(username, hostname, port);\r\n\r\n\u2026\u2026\r\n\r\nsession.connect();<\/pre>\n<p>&nbsp;<\/p>\n<!--themify_builder_content-->\n<div id=\"themify_builder_content-1268\" data-postid=\"1268\" class=\"themify_builder_content themify_builder_content-1268 themify_builder tf_clear\">\n    <\/div>\n<!--\/themify_builder_content-->\n","protected":false},"excerpt":{"rendered":"<p>Introduction JSch stands for Java Secure Shell. It allows you to connect to an ssh remote server. SSH stands for Secure Shell. It provides support for secure remote login, secure file transfer, etc. It can automatically encrypt, authenticate, and compress transmitted data. You can find more information about the JSch library at http:\/\/www.jcraft.com\/jsch\/ &nbsp; We [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1268","post","type-post","status-publish","format-standard","hentry","category-automation","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/1268","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=1268"}],"version-history":[{"count":3,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/1268\/revisions"}],"predecessor-version":[{"id":19612,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/1268\/revisions\/19612"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=1268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=1268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=1268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}