8 Replies Latest reply on Jan 15, 2014 4:20 PM by darren hartford

    SSH example

    darren hartford Expert

      Does anyone have experience setting up an SSH binding in Switchyard, and maybe an example?

       

      My research there is supposedly a camel-ssh component, but also a netty TCP/ssh possibility (neither seem native/first class at the moment). Fuse mentions in their docs the camel-ssh option...this is not an old Fuse project nor have I used Fuse, just cross-checking. :-)

       

      Looking for a short-term version for an integration challenge (versus raw code).

       

      -D

        • 1. Re: SSH example
          darren hartford Expert

          Clarification - this is to setup SSH as a tunnel/transport for payload for a receiving system expecting payload on the port (ssh used for encryption of the channel) w/ user:pass authentication opposed to cert auth.

           

          Not intended for command usage, only for payload and response through the SSH tunnel.

          • 2. Re: SSH example
            Keith Babo Master

            Part of this depends on how much you need to customize the interaction over SSH.  SFTP is available out of the box and uses SSH to secure the file transfer.  If that won't work, then you might want try both the Netty and camel-ssh options to see which one best satisfies your needs.  If you end up trying out camel-ssh, you'll need to add it as an extension component:

             

            Extensions - SwitchYard - Project Documentation Editor

            1 of 1 people found this helpful
            • 3. Re: Re: SSH example
              darren hartford Expert

              Thanks Keith!

               

              I'm going down the extension route with camel-ssh for the first pass to see if good-enough for my usecase or not.

               

              Note: the camel-ftp (SFTP) uses jcraft.jsch instead of mina-sshd used in camel-ssh

               

              See next post...I think the attachment stopped me from posting and I lost everything I typed up the first time....

               

               

              In switchyard.xml, I added as a reference the following:

               

                 <camel:binding.uri configURI="ssh://testuser:testpw@testserver:22">

                 </camel:binding.uri>

               

               

               

              But get the following error:

               

              Caused by: java.lang.ClassCastException: org.switchyard.config.model.composite.v1.V1BindingModel cannot be cast to org.s

              witchyard.component.camel.common.model.CamelBindingModel

                      at org.switchyard.component.camel.common.deploy.BaseBindingActivator.activateBinding(BaseBindingActivator.java:3

              9)

                      at org.switchyard.deploy.internal.Deployment.deployReferenceBindings(Deployment.java:300)

                      at org.switchyard.deploy.internal.Deployment.start(Deployment.java:143)

                      at org.switchyard.as7.extension.deployment.SwitchYardDeployment.start(SwitchYardDeployment.java:101)

                      at org.switchyard.as7.extension.services.SwitchYardService.start(SwitchYardService.java:73)

              • 4. Re: Re: SSH example
                darren hartford Expert

                Attachment is an attempt at camel-ssh 2.10.0 extension for switchyard 1.1

                 

                Install

                explode under /modules/system/layers/soa/

                 

                Modify standalone.xml, append under switchyard subsystem extensions:

                 

                <extensions>
                <extension identifier="org.apache.camel.mvel"/>
                <extension identifier="org.apache.camel.ognl"/>
                <extension identifier="org.apache.camel.jaxb"/>
                <extension identifier="org.apache.camel.soap"/>

                <!-- custom extensions -->

                <extension identifier="org.apache.camel.component.ssh"/>

                 

                </extensions>

                 

                Usage

                 

                In switchyard.xml, add the following xlmns definition if not already there:

                 

                xmlns:camel_1="urn:switchyard-component-camel-core:config:1.1"

                 

                sample reference binding:

                 

                <camel_1:binding.uri configURI="ssh://testuser:testpw@testserver:22"/>

                 

                 

                see other important docs:

                http://camel.apache.org/ssh.html

                Camel URI - SwitchYard - Project Documentation Editor

                Extensions - SwitchYard - Project Documentation Editor

                • 5. Re: SSH example
                  darren hartford Expert

                  Further, it appears this error happens regardless of the component installing correctly or not (or, to say it another way, whether the extension is absent, or is present but not deploying related to dependency issues, or fully deploying without complains).  So it seems more about the camel:binding.uri issue rather than the extension.

                   

                   

                  In switchyard.xml, I added as a reference the following:

                   

                     <camel:binding.uri configURI="ssh://testuser:testpw@testserver:22">

                     </camel:binding.uri>

                   

                  Or also trying this instead:

                   

                  <camel:binding.uri configURI="file://target/output"/>

                   

                  (removing the configuration stops the error).

                   

                  But get the following error:

                   

                  <project>.SwitchYardService: java.lang.ClassCastException: org.switchyard.config.model.composite.v1.V1BindingModel cannot be cast to org.switchyard.component.camel.common.model.CamelBindingModel

                          at org.switchyard.as7.extension.services.SwitchYardService.start(SwitchYardService.java:80)

                          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-ms

                  c-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]

                          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.4.G

                  A-redhat-1.jar:1.0.4.GA-redhat-1]

                          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_45]

                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_45]

                          at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_45]

                  Caused by: java.lang.ClassCastException: org.switchyard.config.model.composite.v1.V1BindingModel cannot be cast to org.s

                  witchyard.component.camel.common.model.CamelBindingModel

                          at org.switchyard.component.camel.common.deploy.BaseBindingActivator.activateBinding(BaseBindingActivator.java:3

                  9)

                          at org.switchyard.deploy.internal.Deployment.deployReferenceBindings(Deployment.java:300)

                          at org.switchyard.deploy.internal.Deployment.start(Deployment.java:143)

                          at org.switchyard.as7.extension.deployment.SwitchYardDeployment.start(SwitchYardDeployment.java:101)

                          at org.switchyard.as7.extension.services.SwitchYardService.start(SwitchYardService.java:73)

                  • 6. Re: Re: SSH example
                    Keith Babo Master

                    I just tested an app with a Camel URI service and reference binding with SY 1.1.0.Final and it worked fine.  Which version of SY are you using?  First thing to do here is to determine that Camel URI bindings are working in your install in the first place.  For that, you can deploy a simple app which uses the Camel URI binding with a Camel component we already include.  I have attached an example which uses a file endpoint with the Camel URI binding if you want to just use that.  If that works, then we know it's an issue with the packaging of the ssh module.

                    1 of 1 people found this helpful
                    • 7. Re: SSH example
                      darren hartford Expert

                      hmm...I'm using a fuse 601 installer app server (it appears this was based on EAP 6.0) and updated the modules with the switchyard 1.1.0.FINAL (it says for EAP 6.1 though.....), so maybe I'm hurting myself there.

                       

                      I already tried a simple file:// camel URI binding and that doesn't work either, so probably my environment problem. Thanks for the cross-check, this puts a damper in my progress :-)

                      • 8. Re: SSH example
                        darren hartford Expert

                        (upgraded to eap6.1 w/ switchyard 1.1...although the problem may have been unrelated).

                         

                        Same issues, but in your example (that works) you have this at the top:

                         

                        xmlns:camel="urn:switchyard-component-camel:config:1.1"  xmlns:camel_1="urn:switchyard-component-camel-core:config:1.1"

                         

                        and reference the bindings as

                         

                          <camel_1:binding.uri name="camel1" configURI="file:///tmp/outbox"/>

                         

                        My ignorance, that simple change seemed to make the deployment happier.  I'm still unfamiliar on how to use the camel-ssh effectively so still trying that out, but confirm deployment when modify the switchyard.xml with a second camel_1 deployment using camel-core:config.

                         

                        <camel_1:binding.uri configURI="ssh://testuser:testpw@testserver:22"/>

                         

                        (the module above is making SSH calls, so it is actively doing something :-).

                         

                        EDIT: confirmed. using a route.xml entry like this prior to sending to a reference:

                         

                          <setBody>

                            <constant>ls$#10;</constant>

                          </setBody>  

                         

                        and the binding.uri points to a linux ssh server using normal credentials, get back the list of directories.

                         

                        sidenote, it appears to assume \n for everything, so if you have a legacy process that does not send \n, it may not understand you finished sending content.