Quantcast

Camel SSH - dynamic values

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Camel SSH - dynamic values

urwithsumit
I am trying to use Camel ssh component as a producer. I am passing username and password as a dynamic parameter. With camel Version 2.18.2, my uri looks like below:
 
.to("ssh://localhost?username=${header.USERNAME}&password=${header.PASSWORD}&pollCommand=features:hostname%0A")

With this uri, I keep getting error: Caused by: org.apache.camel.RuntimeCamelException: Failed to authenticate username ${header.USERNAME}

The above uri works if i hard code the username and password value.
This makes me wonder if supplying the values for username & password dynamically is supported by this component or not?.

If not, than what alternative approach i can take to achieve the same objective.

Regards
Sumit
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Camel SSH - dynamic values

urwithsumit
Well, I was immediately able to figure out the alternate approach for it.

Map<String, String> map = exchange.getIn().getBody(HashMap.class);
                                       
exchange.getIn().setHeader("USERNAME", map.get(HeaderConstant.USER_NAME));
exchange.getIn().setHeader("PASSWORD", map.get(HeaderConstant.PASSCODE));

getContext().createProducerTemplate().requestBody("ssh://localhost?username="+map.get(HeaderConstant.USER_NAME)+"&password="+map.get(HeaderConstant.PASSCODE)+"&pollCommand=features:hostname%0A", map);

I have another question though, with user id and password it works fine. How to make it work against a randomly generated RSA token?

Most of the example i see are with ssh keys but i dont have this scenario applicable. Any pointers?

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Camel SSH - dynamic values

Claus Ibsen-2
In reply to this post by urwithsumit
See this FAQ
http://camel.apache.org/how-to-use-a-dynamic-uri-in-to.html

On Tue, Apr 11, 2017 at 11:33 PM, urwithsumit <[hidden email]> wrote:

> I am trying to use Camel ssh component as a producer. I am passing username
> and password as a dynamic parameter. With camel Version 2.18.2, my uri looks
> like below:
>
> .to("ssh://localhost?username=${header.USERNAME}&password=${header.PASSWORD}&pollCommand=features:hostname%0A")
>
> With this uri, I keep getting error: Caused by:
> org.apache.camel.RuntimeCamelException: Failed to authenticate username
> ${header.USERNAME}
>
> The above uri works if i hard code the username and password value.
> This makes me wonder if supplying the values for username & password
> dynamically is supported by this component or not?.
>
> If not, than what alternative approach i can take to achieve the same
> objective.
>
> Regards
> Sumit
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-SSH-dynamic-values-tp5797435.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Camel SSH - dynamic values

urwithsumit

Thanks Claus for this pointer. I will try this approach today.

Any advice on how i can make a SSH login with username and a RSA Token ex: 87632345?

Regards,
Sumit
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Camel SSH - dynamic values

Zoran Regvart-2
Hi Sumit,
not sure if you'll shoot yourself in the foot, but you could do change
component's configuration from a processor, like:

    from("direct:s").process((exchange) -> exchange.getContext()
        .getComponent("ssh", SshComponent.class)
        .getConfiguration()
        .setPassword("..."))
    .to("ssh:...");

zoran

On Wed, Apr 12, 2017 at 7:34 PM, urwithsumit <[hidden email]> wrote:
> Any advice on how i can make a SSH login with username and a RSA Token ex:
> 87632345?




--
Zoran Regvart
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Camel SSH - dynamic values

urwithsumit
@Claus, toD() did worked for user id and password.

@Zoran, the approach gives a null pointer exception for user id,  RSA token combination. I did not tried though with the password. For dynamic value i thus will go with toD()


Still struggling to get it work with RSA token code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Camel SSH - dynamic values

Claus Ibsen-2
Hi

I logged a ticket so we can support username/password headers in the future
https://issues.apache.org/jira/browse/CAMEL-11152

Contributions is welcome

On Thu, Apr 13, 2017 at 3:40 AM, urwithsumit <[hidden email]> wrote:

> @Claus, toD() did worked for user id and password.
>
> @Zoran, the approach gives a null pointer exception for user id,  RSA token
> combination. I did not tried though with the password. For dynamic value i
> thus will go with toD()
>
>
> Still struggling to get it work with RSA token code.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-SSH-dynamic-values-tp5797435p5797545.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Loading...