• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java SSH method on Unix

 
terry Kiernan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

Anyone know how I can ssh using a java method into another machine where authentication has already been setup for the user ...

Please Help as I am stuck , I was using a third party trilead plugin methods but it looks like that plugin methods doesn't work .

Thanking you ,
T
 
sangram mhatre
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have used a third party api from jscape and it works fine
and is simple to use . You can try the same .
http://www.jscape.com/articles/ssh_using_java.html
 
terry Kiernan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for that ... BUT I don't want to enter the password .. I have already authenticated the user so s/he should be able to ssh just passing the hostname and username no Need for password ...

It looks like Jscape requires the password to be passed in ...???
 
sangram mhatre
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No , you dont have to .
you can refer the api at , http://www.jscape.com/secureinetfactory/docs/javadoc/index.html

Check for ssh constructor .
 
terry Kiernan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah have been looking at that class definitions but I don't see a constructor that only takes the username and hostname ... Maybe i am missing something ???...

Thanks your help is been much appreciated ...

BTW : this is not Freeware ? had you to purchase the jscape package ..
 
terry Kiernan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am geteting the following error when i just pass username and hostname to the construtor
ymbol : constructor SshParameters(java.lang.String,java.lang.String)
location: class com.jscape.inet.ssh.util.SshParameters
SshParameters sshParams = new SshParameters(hostname,username);
 
Carey Evans
Ranch Hand
Posts: 225
Debian Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you expand on what you mean when you say that you �have already authenticated the user�, and why this should let you access another machine without logging in?
 
terry Kiernan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Carey,

when i say that I mean the user can login into the hostname without providing the password . The the rsa and dsa keys have been generated outside the application for that user.

So for eg the user can do the following from one host to another remote host where authenticiy has ben established.

ssh -l <username> <hostname>
 
Carey Evans
Ranch Hand
Posts: 225
Debian Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With Trilead SSH, you can use Connection.authenticateWithPublicKey() with the filename of the key. It won't find the key automatically.
 
terry Kiernan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carey,
there is a method
boolean res = conn.authenticateWithNone(username);

if (res == true)
{
("No authentication needed.");
}
if (res == false)
{
("Authentication needed:");

}
so that should do it But No ....
 
Carey Evans
Ranch Hand
Posts: 225
Debian Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"none" authentication is used in SSH when the connection doesn't need to be authenticated at all, not when it uses public key authentication.

I believe "none" will only work with OpenSSH if you've configured "hostbased" authentication on both the client and the server, which is not a simple process. I don't know if any Java SSH clients support it, but I also doubt that you're using it.
 
terry Kiernan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using the Jscape package now to do use the ssh session within java ..
How ever it is a licenced package ... Do I have to purchase the licence for it to run with this .. Is there any ssh session package that is GPL and free to use ?
As anyone been faced with this before ?

Thanks
 
Rusty Shackleford
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are going to do that, why bother with authentication?

What you are asking is how to authenticate an IP address and then assume that only the one person who authenticated will use the machine.

See a problem with that?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!