Discuss (FTP) and (SFTP, FTPS and SCP), our Java file transfer clients.
no avatar
User

rozanalitasy

Posts

12

Joined

Sat Jun 28, 2008 12:25 am

Does not establish a connection to sshftp....

by rozanalitasy » Tue Jul 01, 2008 1:57 pm

no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

Re: Does not establish a connection to sshftp....

by support2 » Tue Jul 01, 2008 3:05 pm

no avatar
User

rozanalitasy

Posts

12

Joined

Sat Jun 28, 2008 12:25 am

by rozanalitasy » Tue Jul 01, 2008 6:12 pm

i am using webservices to connect to the sshftp,i have a sshftpclient class where i am implementing methods to establish the connection.

The piece of code is as follows:

sshftp = new SSHFTPClient( );


sshftp.setRemoteHost(props.getProperty("ftpMachine"));
sshftp.setRemotePort(22);
System.out.println("set a remote port");
// Turn off server validation (ONLY do this when testing)
sshftp.getValidator().setHostValidationEnabled(true);
String str = sshftp.getRemoteHost();
com.enterprisedt.net.ftp.ssh.SSHFTPPublicKey str1 = sshftp.getHostPublicKey(str);
System.out.println("host public key :" +str1);

sshftp.disableAllAlgorithms(SSHFTPAlgorithm.KEY_PAIR);

sshftp.setAlgorithmEnabled(SSHFTPAlgorithm.KEY_DSA, true);

System.out.println("get enabled algorithm :" +sshftp.getEnabledAlgorithms());

System.out.println("bit length :" +str1.getBitLength());
System.out.println("algorithm type :" +sshftp.getType());
sshftp.getValidator().addKnownHost("devlserv.cup.hp.com","/home/mohapatr/publickeyfile/file1.pub");

System.out.println("loading known hosts");

sshftp.setAuthentication("/home/mohapatr/publickeyfile/file1",props.getProperty("ftpUsername"),"Libra04");

System.out.println("authentication successful");



sshftp.setTimeout(60000); // "Gimme a minute!" hehe
// connect to the server
sshftp.connect();

When i run this through a client code which invokes the sshftpclient on the server side i get the ERROR!!! as

The host signature is invalid or the host key was not accepted!

on the server.

changing the addKnownHost() to
sshftp.getValidator().loadKnownHosts("/home/mohapatr/publickeyfile/file1.pub");

i get a ERROR!! as
Bad Base64 input character at 10: 64(decimal)
again on the server side....

This is a public key i generated using ssh-keygen

file1.pub:-

ssh-dss AAAAB3NzaC1kc3MAAACBAPjXY3x4W+VNi0w3FAMuJyfLYmxeL+S0MSauT7uw/HGZaKAoLu1i
ZLt3GAI3UaHroCb4cj6FB3QNA9vtelcSB1XwKWOvX1YCqbMh0NGYoWaE8I/8vUfVvvx/npARfRVgYAki
XKj/jB/R56TobaqMamHx0vcRFXjfy7Ot/eH6v+ozAAAAFQC0eEku2m7fjXo1kyNdHBqGpLhcNQAAAIAJ
3FguXRswHIzQ1X4i+yBiksZ6FLUyh84tTHfs70vWNz8A+TMGzik3dEfdWrmI6on4pamm3rbZCfYrZSwL
iHyC3JRsKm+XU+cjWYILv5WgIcAxmq8Pyl8QskEOKHmoXMrZPUa4+e3vq0oiZU1gAn4JjlYKUkaCZoCN
jeC6m6loxAAAAIBu9e+9t4A9nl63wArGxWxtJ7l5BmKOqGk4lnfvAGwjybpr0KeZnUjArMXbrAOgbDWU
M9dt0VewGGzVdQT9IcAcHa8M4lbR4cJEVKYu8FWpy8yzc1kc+rKUwtHnY0OTik/5PgEkoKri+nyff+V+
qfjjHu90m/a3MORZ9r1rBJKixg== SHARMISTHA@shell.sf.net



Anything else you require????

Kindly help me.....................
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

by support2 » Tue Jul 01, 2008 7:25 pm

The correct method is addKnownHost("devlserv.cup.hp.com","/home/mohapatr/publickeyfile/file1.pub");

However, is this the public key of the server? If not, you will get the error you experienced. You can't just generate a public key - you need the public key belonging to the server you need to connect to.

You can use

sshftp.getValidator().setHostValidationEnabled(false);

to skip server validation initially.

Similarly, for sshftp.setAuthentication(), you need to supply your *private* key - but your public key must first be registered with the SSH server, otherwise public key authentication will not work.

You may want to start with password authentication first.

There's a lot of information in the Developer's Guide on these things.
no avatar
User

rozanalitasy

Posts

12

Joined

Sat Jun 28, 2008 12:25 am

by rozanalitasy » Tue Jul 01, 2008 8:15 pm

i have already used

sshftp.getValidator().setHostValidationEnabled(false);

i get a perfect output through that.But knowing that it shows a low security if the validation is set false,I am implementing

sshftp.getValidator().setHostValidationEnabled(true);

does sshftp.getHostPublicKey(sshftp.getRemoteHost()); gives the public key of the server???

when i use this method it gives me

host public key :com.enterprisedt.net.ftp.ssh.SSHFTPPublicKey@b25494ad

as the output..........

Is this the one you were talking about???
And one more thing, where can i get the private key to set authentication using it???Any methods that may help me???

Please help me...........
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

by support2 » Wed Jul 02, 2008 7:26 am


Who is online

Users browsing this forum: No registered users and 13 guests

Powered by phpBB ® | phpBB3 Style by KomiDesign