I am, I parse a key file and load it. I also verify that I can open the key using the pass Phrase. I have also connected to the server with Putty and the key to make sure that it works. I am using J2ssh SSHtools.
Main Topics
Browse All TopicsI am writing a Servlet that will SSH to a Linux machine and run a command. I am authenticating via a private key. I am watching the SSH logs on the Linux server and my application hangs at the following: debug1: expecting SSH2_MSG_NEWKEYS. I am not sure what I am missing. I am not sure what is it looking for. Any help or guidance would be greatly appreciated.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I am not getting much information that is useful. I have removed the part of my code that tries to authenticate via the private key and the results are the same. It is not finishing the hand-shake so I can pass on my authentication information. I have searched for information on SSH2_MSG_NEWKEYS. I am not finding much that is useful. The problem is I am not sure if it is a setting on the server, maybe an obscure network setting, or an issue with my code. Very Frustrating.
I had a look for info on SSH2 and i must say that's not entirely easy to find either.
I think it's probably worth looking into the the client settings of your api, as there might be something like a setting that needs to be set explicitly.
Failing that, it might be a good idea to try to contact the authors. Keep us posted!
I have used 'jsch' libraries to run a linux command from a Java desktop application. Not sure of the SSHTools.
Why dont you try http://www.jcraft.com/jsch
I may have to try Jcraft, and I agree about the settings for the api. The properties conf that you use to manage the connection is not well documented. I think I will try jcraft. Also, I have reached out to a red hat engineer to see if they have any suggestions. I will let you know. Thank you for your time and effort on my behalf.
The site itself has list of examples. Please go thru it...
http://www.jcraft.com/jsch
You might be interested in Shell.java or Exec.java. Please go thru the description of each program
Here is the code that I am using. Here are the imports.
import com.sshtools.j2ssh.connect
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletExcep
import javax.servlet.http.HttpSer
import javax.servlet.http.HttpSer
import javax.servlet.http.HttpSer
import java.io.File;
import com.sshtools.j2ssh.SshClie
import com.sshtools.j2ssh.authent
import com.sshtools.j2ssh.authent
import com.sshtools.j2ssh.session
import com.sshtools.j2ssh.transpo
import com.sshtools.j2ssh.transpo
import com.sshtools.j2ssh.configu
import com.sshtools.j2ssh.configu
import java.io.BufferedReader;
import java.io.InputStreamReader;
I am using version 0.2.9
http://sourceforge.net/pro
Thank you for your help, if it works for you then I know that I have a server issue.
Sorry for the late reply. I do not have a known host file, therefore every time I connect, it wants me to verify the host. I chose the option to ignore host verification and it worked fine. I created a known host file so I can avoid the issue in the future. Again, I really appreciated your help trouble shooting this.
Business Accounts
Answer for Membership
by: CEHJPosted on 2009-11-06 at 07:07:12ID: 25759701
Are you sure that key is accessible to your app?