Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
15.9k views
in Java FTP by (500 points)
The loadknownhosts() returns me with this error :

Bad Base64 input character at 3: 64(decimal)


My application goes like this:-

sshftp = new SSHFTPClient( );
sshftp.setRemoteHost(ftpMachine);
sshftp.setRemotePort(22);
sshftp.getValidator().setHostValidationEnabled(true);
sshftpvalidator.addKnownHost(ftpMachine,"~/.ssh/id_rsa.pub");
sshftp.setAlgorithmEnabled(SSHFTPAlgorithm.KEY_RSA, true);
sshftpvalidator.loadKnownHosts("~/.ssh/id_rsa.pub");
sshftp.setAuthentication(ftpUsername,ftpPassword);
sshftp.connect();

My code stops after sshftp.setAlgorithmEnabled(SSHFTPAlgorithm.KEY_RSA, true); and throws the above error.
Kindly help me in resolving the issue as am unsure of the cause for the error.

11 Answers

0 votes
by (162k points)
You aren't loading a known_hosts file. It is a different format to id_rsa.pub, which is a public key file.

Using addKnownHost(ftpMachine,"~/.ssh/id_rsa.pub") is sufficient (it is an alternative), you don't need to call loadKnownHosts().
0 votes
by (500 points)
I already tried doing that as you have asked me to use either
addKnownHost(ftpMachine,"~/.ssh/id_rsa.pub") or loadKnownHosts().

I did it again by removing the loadKnownHosts() from my apps but it returns me the error saying

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

Where am i going wrong???

sshftp = new SSHFTPClient( );
sshftp.setRemoteHost(ftpMachine);
sshftp.setRemotePort(22);
sshftp.getValidator().setHostValidationEnabled(true);
sshftpvalidator.addKnownHost(ftpMachine,"~/.ssh/id_rsa.pub");
sshftp.setAuthentication(ftpUsername,ftpPassword);
sshftp.connect();

Its not able to invoke the connect().

HELP ME!!!!!!!!!!!!!!
0 votes
by (162k points)
Please create a log file at the ALL level and email it (zipped up) to support at enterprisedt dot com.

See the Dev Guide for creating a log file
0 votes
by (500 points)
As discussed earlier i am facing the problem of

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

My apps is as follows:-

log.info("Creating SFTP client");
sshftp = new SSHFTPClient( );

sshftp.setRemoteHost(props.getProperty("ftpMachine"));

sshftp.setRemotePort(22);
System.out.println("set a remote port");

log.info("host validation enabled");
sshftp.getValidator().setHostValidationEnabled(true);
System.out.println("host validation done");

log.info("adding known hosts");
sshftpvalidator.addKnownHost(ftpMachine,"~/.ssh/id_rsa.pub");
System.out.println("adding known hosts");

log.info("Setting user-name and password");
sshftp.setAuthentication(ftpUsername,ftpPassword);
System.out.println("authentication successful");

sshftp.setTimeout(60000);
sshftp.connect();

And the error is as follows:-


INFO [com.hp.swmt.esdwh.sweet.sweetSSHFtpClient] 8 Sep 2008 22:59:23.785 : Creat
ing SFTP client
INFO [puretls] 8 Sep 2008 22:59:24.161 : PureTLS debug level=0
INFO [LicensePropertiesBase] 8 Sep 2008 22:59:24.363 : Licence expiry date: 31 D
ec 9999
INFO [LicensePropertiesBase] 8 Sep 2008 22:59:24.363 : Production licence
set a remote port
testing sshftp 4
INFO [com.hp.swmt.esdwh.sweet.sweetSSHFtpClient] 8 Sep 2008 22:59:24.368 : host
validation enabled
host validation done
INFO [com.hp.swmt.esdwh.sweet.sweetSSHFtpClient] 8 Sep 2008 22:59:24.368 : addin
g known hosts
adding known hosts
INFO [com.hp.swmt.esdwh.sweet.sweetSSHFtpClient] 8 Sep 2008 22:59:24.426 : Setti
ng user-name and password
authentication successful
INFO [SSHFTPClient] 8 Sep 2008 22:59:24.451 : SSHFTPClient settings validated.
INFO [TransportProtocolCommon] 8 Sep 2008 22:59:24.635 : Timeout=60000
INFO [TransportProtocolCommon] 8 Sep 2008 22:59:24.643 : Wait for state update t
INFO [TransportProtocolCommon] 8 Sep 2008 22:59:24.644 : Wait for state update t
INFO [cryptix] 8 Sep 2008 22:59:24.708 : GLOBAL_TRACE=false
INFO [cryptix] 8 Sep 2008 22:59:24.708 : GLOBAL_DEBUG=false
INFO [cryptix] 8 Sep 2008 22:59:24.708 : GLOBAL_DEBUG_SLOW=false
INFO [TransportProtocolCommon] 8 Sep 2008 22:59:24.731 : Wait for state update t
INFO [DhGroup1Sha1] 8 Sep 2008 22:59:24.740 : Starting client side key exchange.
ERROR [TransportProtocolOutputStream] 8 Sep 2008 22:59:25.49 : sendMessage() fai
ERROR [TransportProtocolOutputStream] 8 Sep 2008 22:59:25.50 : sendMessage() fai
ERROR [TransportProtocolCommon] 8 Sep 2008 22:59:25.242 : The Transport Protocol
java.net.SocketException: Socket closed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:134)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:220)
@ at java.io.BufferedInputStream.read(BufferedInputStream.java:277)
at com.enterprisedt.net.j2ssh.transport.A.A(Unknown Source)

at java.net.SocketInputStream.socketRead0(Native Method)


at java.io.BufferedInputStream.read(BufferedInputStream.java:277)



Kindly let me know what can i do to resolve this issue....
0 votes
by (162k points)
We need an entire log file set to ALL level emailed to us please - the log above is not sufficient.

It would be very helpful if you also emailed a similar log file with sshftp.getValidator().setHostValidationEnabled(false);
0 votes
by (162k points)
Just thinking about this problem a bit more, are you sure that you are using the *server's* public key here?

There's a pretty good chance that ~/.ssh/id_rsa.pub is actually *your* public key, not the server's - they are completely different.

If you do have a known_hosts file available, please try that via loadKnownHosts() rather than using addKnownHost().
0 votes
by (500 points)
Well first let me inform you with a piece of info that i am using the version 2.0.0 and am trying to enable
sshftp.getValidator().setHostValidationEnabled(false) i.e.,

sshftp.getValidator().setHostValidationEnabled(true) in my apps.

i have generated the public keys through

ssh-keygen -t RSA

followed by performing the copying and pasting of the keys at the client's authorized_keys.

I even want to inform you that everything goes fine when i do it practically over the server prompts.

But my apps stops with the error which exactly tries to do the same.

Now because my public key is already available at both the places (server & client) i was using
addKnownHosts(ftpMachine,"~/.ssh/id_rsa.pub").

My apps requirement is to only have known and authorized users to access SSHFTP and so we are generating the keys outside the app and not through the apps.

I am still stuck at the place with the log i previously posted.

I have no issues with
sshftp.getValidator().setHostValidationEnabled(false);

Kindly let me know if i am missing something somewhere.
0 votes
by (162k points)
addKnownHosts() requires the SERVER'S public key.

It looks to me like you are using the CLIENT'S public key with addKnownHosts(). This WON"T WORK. They have absolutely nothing in common.

You need a copy of the SERVER'S public key here.

The best place to get it is normally in a file called known_hosts.

That's why loadKnownHosts() is normally used to load the known_hosts file.
0 votes
by (500 points)
I tried doing the way you mentioned in your reply i.e.; by changing the keys

If i am using loadKnownHosts(hostfile) it gives me

Bad Base64 input character at 3: 64(decimal) error

And if i change it to addKnownHost(ftpmachine,"~/.ssh/id_rsa.pub)

it gives me the The Transport Protocol thread failed : Socket closed error

I am not sure as what should be done.
0 votes
by (162k points)
Are you using loadKnownHosts("~/.ssh/known_hosts")?

If so and you are still getting an error, please email us the known_hosts file and the log file set to the ALL level.

Categories

...