com.jcraft.jsch.JSchException: reject HostKey: serverName

Today I was working on a Ant target to upload file to server using SCP task which using jsch-0.1.49.jar API. Below is the syntax for same in Ant build.xml. You need to add the API file in class path.

<target name=”copyFileToServer”>
        <echo>::::::::copyFileToServer Example::::::::::::</echo>
    <scp file=”Sample.txt” todir=”${svn.username}:${svn.password}@${hostname}:/tmp/” verbose=”true” port=”2222″  failonerror=”true”/>
  </target>

When I tried this I faced “reject HostKey” error. Reason of error was server was not listed in my known hosts list. So in order to fix this you have two options either add that server to known host list or

Continue reading “com.jcraft.jsch.JSchException: reject HostKey: serverName”

Download sequence of files using Curl

In day to day life we used to download useful stuff from world wide web, sometime requirement to download sequence of files, one way is to do it manually by clicking individual links or automate the download using Curl.

Showing you that next, how we can do it.

grab Curl from : http://curl.haxx.se/download.html

Curl has the ability to set sequences (including with leading zeroes, and alphanumeric sequences) as part of the download command which makes it a lot easier. This is all covered in the man page so I suggest reading it for a complete understanding of the options available.
Continue reading “Download sequence of files using Curl”

jQuery Mobile bugs, tips and tricks

jQuery mobile is a framework build upload on jQuery and jQuery UI foundation, which is a unified, HTML5-based user interface system for all popular mobile device platforms. Now days jQuery becoming popular among mobile sites. In spite of bugs (couple of explained below) this should not put you off developing with the framework as no framework is 100% complete, it get improvements/enhancements on going with users feedback. One of the major factor why jQuery Mobile becoming popular is easy to learn,  early adoption of jQuery mobile by mobile sites and a large range of online support, threads and documentation available. Almost all bugs we encountered are known to development team and they definitely will fix those in future releases.

Many of the bugs are unique to the older Android devices (like 2.2, 2.3), therefore with the recent news that Google Chrome is to become the standard browser on Android 4.0 and above means that, jQuery mobile will be more consistent and will offer gr8 performance across devices. Currently, mobile chrome is available through Android Market in Beta.

One interesting fact, was when I ran CSS3/HTML5 compatibility test on Android default browser I got approx 188 points whereas when ran on Chrome I got approx 300 points which means quite a lot improvement and support for new features introduces with CSS3/HTML5.

Link: http://www.google.com/intl/en/chrome/android/ (Supported on Android 4.0+)

Couple of Known Bugs Continue reading “jQuery Mobile bugs, tips and tricks”

UNIX: How to Automate SSH Login

Yesterday, I was working on some shell script piece for my project and I came across a situation where I have to copy some files from one server to another using ‘scp’ command and also some time have to execute some command on other server.  One requirement was we don’t need to pass the password of functional id inside the script.

User should be able to login to other server without password using command  “ssh -l username remotehost”.

For this I used SSH public key based authentication as below:-

Continue reading “UNIX: How to Automate SSH Login”

java.security.InvalidKeyException: Illegal key size or default parameters

I was working on webservice call where my code was breaking in RAD during decrypting the password of keystore. I encountered below error:

Caused by: java.security.InvalidKeyException: Illegal key size or default parameters
    at javax.crypto.Cipher.a(DashoA13*..) ~[na:1.6]
    at javax.crypto.Cipher.a(DashoA13*..) ~[na:1.6]
    at javax.crypto.Cipher.a(DashoA13*..) ~[na:1.6]
    at javax.crypto.Cipher.init(DashoA13*..) ~[na:1.6]
    at javax.crypto.Cipher.init(DashoA13*..) ~[na:1.6]

Continue reading “java.security.InvalidKeyException: Illegal key size or default parameters”

Caused by: java.security.UnrecoverableKeyException: Cannot recover key

During deployment of my code on server I faced below issue signature issue:

org.apache.axis2.AxisFault: Error in signature with X509Token
    at org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:70)
    at org.apache.axis2.engine.Phase.invoke(Phase.java:318)
    at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:254)
    at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:419)
    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
 Caused by: org.apache.rampart.RampartException: Error in signature with X509Token
    at org.apache.rampart.builder.AsymmetricBindingBuilder.doSignature(AsymmetricBindingBuilder.java:746)
    at org.apache.rampart.builder.AsymmetricBindingBuilder.doSignBeforeEncrypt(AsymmetricBindingBuilder.java:419)
    at org.apache.rampart.builder.AsymmetricBindingBuilder.build(AsymmetricBindingBuilder.java:95)
    at org.apache.rampart.MessageBuilder.build(MessageBuilder.java:147)
    at org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:64)
    … 102 more

Caused by: org.apache.ws.security.WSSecurityException: Signature creation failed; nested exception is:
    java.security.UnrecoverableKeyException: Cannot recover key
    at org.apache.ws.security.message.WSSecSignature.computeSignature(WSSecSignature.java:721)
    at org.apache.rampart.builder.AsymmetricBindingBuilder.doSignature(AsymmetricBindingBuilder.java:737)
    … 106 more
Caused by: java.security.UnrecoverableKeyException: Cannot recover key
    at sun.security.provider.KeyProtector.recover(KeyProtector.java:311)
    at sun.security.provider.JavaKeyStore.engineGetKey(JavaKeyStore.java:121)
    at sun.security.provider.JavaKeyStore$JKS.engineGetKey(JavaKeyStore.java:38)
    at java.security.KeyStore.getKey(KeyStore.java:763)
    at org.apache.ws.security.components.crypto.CryptoBase.getPrivateKey(CryptoBase.java:216)
    at org.apache.ws.security.message.WSSecSignature.computeSignature(WSSecSignature.java:713)
    … 107 more

Continue reading “Caused by: java.security.UnrecoverableKeyException: Cannot recover key”

Count lines of multiple similar files in unix

In continuation to my earlier post regarding concatenation similar files into one. I am writing this post to demonstrate counting lines of similar kind of files in a given directory and sub-directory.

Below command will find all the logs with given name pattern inside the directory including sub directories and then WC will count it’s lines and display on screen in total.

Continue reading “Count lines of multiple similar files in unix”

Concatenate/merge/join Multiple Text Files in Windows

Last night I got many log files from 8 different servers, all the servers have date wise log files. I separated out similar logs and kept in a folder, now as per requirement team needs the one type of log in consolidated manner means “USAGE.log” of all days and servers in one USAGE-Consildated.log file.

I was searching for some utility on Google but not get any. Later I thought about DOS Batch command to do the same but a simple copy command did it for me.

Continue reading “Concatenate/merge/join Multiple Text Files in Windows”