EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Synapse and SSH server

Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.
#4614
Posted: 01/02/2008 17:43:03
by Tony Caduto (Basic support level)
Joined: 12/31/2007
Posts: 23

Hi,
I am trying to get the SSH server to work with synpase.
I created a console application for testing that runs as the listener and when a connection comes in it creates a Tthread object that contains the ssh server object.
I have a loop in the thread object like this:

procedure Tclientthread.connect_loop(sock: TTCPBlockSocket);
var
command:string;
begin
fsshserver.Open;
while (not terminated) and (sock.LastError = 0) do
begin
if sock.CanRead(1000) then
//call the SSH server data available here
fsshserver.DataAvailable();
sleep(50);
end;
fsshserver.Close();
end;

Listener is as follows:

sock:=ttcpblocksocket.Create;

with sock do
begin
try
EnableReuse(true);
CreateSocket;
if lasterror > 0 then
raise exception.Create(LastErrorDesc+ ' '+intTostr(sock.LastError));
setLinger(true,300);
if lasterror > 0 then
raise exception.Create(LastErrorDesc+ ' '+intTostr(sock.LastError));
bind('0.0.0.0','22');
if lasterror > 0 then
raise exception.Create(intTostr(sock.LastError)+ ' ('+LastErrorDesc+')'+#13+#10+'Please correct by stopping the conflicting server, or by changing the default port of this server.');
listen;
if lasterror > 0 then
raise exception.Create(LastErrorDesc+ ' '+intTostr(sock.LastError));

while true do
begin
if canread(1000) then
begin
ClientSock:=accept;
if lastError = 0 then
Tclientthread.create(ClientSock)
else //accept failed
begin
//writelog(LastErrorDesc+ ' '+intTostr(LastError) + ' (Listner Thread) ','Error');
end;
end;
end;

except
on e:exception do
begin
//writelog(e.Message + ' (Listner Thread) ','Error');

end;
end;


I am kind of basing this from the C# example because I can't seem to find the Delphi sockets in Delphi 2007, plus the C# example actually seems closer to the way Synapse works.

I don't really know c# at all but it seems to be implementing it the same at the basic level by creating a session object then firing off a thread to read from the client. (which is what a Tthread object does)

Any help would be appreciated. I can post my sample project if needed.

Thanks,

Tony

#4616
Posted: 01/02/2008 18:17:50
by Tony Caduto (Basic support level)
Joined: 12/31/2007
Posts: 23

Forgot to add, I keep getting a Compression Error invalid packet, then it disconnects.
I have attached the project. I am just trying to learn this thing, so it's kind of messy right now :-)

I am loading the following key from a text file:

-----BEGIN RSA PRIVATE KEY-----
MIICXwIBAAKBgQCvoU/7h6gGXeOXo9wOZ7U5HSC6J4soLyUDbM1i9fAtBQlWELtZ
MIpCx3hEzHOJI8GVlNds+XYIB3YGRZfVNiM/y3vx9xpCyJRM0EhTvC9FC0xfrMCg
2WVN/65e/ATsB7J4RG35YqbElrEKho9sehaULAuNsV/5VCUPNrB2g2JOvQIEAAEA
AQKBgAFrmov8Mt2qULbfOl5bdFm75JHc1AFFMFVwwdB1ELYsfkDV7c3w2I1ls5FK
3fxT77LX+04ETnIOLWQrl+i/gVV1TkhmCbO+pUelATnKeQ8WdLJxOXGNB4oPuwgR
GhkJnUUmTbJTcm6jdJhft6c0e3xxqeQpharhWaJIlo4sdH2BAkEA4QjCwJCJK/ah
XXwnTeNKcj7aqMqM+Lk2baM6ESEhI5nRL/MKo5BePztLD4I1Vob5YgqvLIHXS+gk
UC4rJJCNkQJBAMfMM+No/Bm0tudEiz+EOKidBoCin7mBDzqSfMMz6ALcY6nOrIDl
Fy5KW8/p/hPFQVu2kYTzMP9LlcgoFcARiG0CQQCLK9LeKsVa1h235jecmOwKucqb
RyFmFY2Owrr/qwCGtvNDd0jmHTvcWTwzrDB2geUreDYcDXTsMfZ7TAJMi8WxAkEA
vjWx0HZKS064MkQXLUj7h8q2PhCUb05m6SQ8krn/z3lxiF+x6qQvBWrVLYNe2AOa
zW1p7GB57RJQblV7H3eRoQJBAK2jdC672ias8i70d5G2rUUaZ9prny07idawuw5W
2x6+GSMGSEu0JqxU/2zEo7mkUuUis+lXZlR2LNvEfRCMuHU=
-----END RSA PRIVATE KEY-----



[ Download ]
#4621
Posted: 01/03/2008 04:28:49
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

Hi.
So it seems that TCP connection goes ok, and error is fired by the SSH server.
Which client you are using to connect to the SSH server?
Also try to disable server compression by setting Server.CompressionAlgorithms[SSH_CA_ZLIB] property to false.
#4622
Posted: 01/03/2008 09:06:35
by Tony Caduto (Basic support level)
Joined: 12/31/2007
Posts: 23

Hi,
was connecting with the latest snapshot of putty.

I will try setting the CompressionAlgorit­hms to false.

My goal is just to get it working in the very basic of ways, no logging at first and I want to allow any password or user to login, which I believe I just have to set accept to true in the events that correspond to login. I am not concerned about security right now as I just want to get the hang of things.


Thanks,

Tony
#4623
Posted: 01/03/2008 09:21:42
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

PuTTY should not cause any problems.
Btw, error about compression is fired by the PuTTY, or by the server?
if disabling compression will not help you, please attach your sample project here to check it.
#4624
Posted: 01/03/2008 10:19:12
by Tony Caduto (Basic support level)
Joined: 12/31/2007
Posts: 23

Hi,
The sample project is attached in the reply with the key. (Created: 01/02/2008 18:17:50)

The error is being returned from the server to putty.

I have attached the latest project to this reply. The project is kind of messy because I don't know what I am doing yet with SBB :-) I only want to get a bare bones example working with Synapse, no logging and just let anyone login.

Do you know what unit SSH_CA_ZLIB is defined in? I can't find it because I don't have the source, only DCUs.

Thanks,

Tony


[ Download ]
#4625
Posted: 01/03/2008 10:26:33
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

Sorry, I missed line with attach when was reading the message at first time.
I will now look over the project.

You can find all documentation at http://www.eldos.com/documentation/sbb/documentation/toc.html
The constant I mentioned is defined in the unit SBSSHConstants.
#4626
Posted: 01/03/2008 10:42:38
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

Also, try to use RecvBufferEx method in place of RecvBuffer, because as noted in Synapse documentation, it waits for a MaxSize data or disconnects, and MaxSize could be larger than real packet size sent by the client.
#4627
Posted: 01/03/2008 11:21:24
by Tony Caduto (Basic support level)
Joined: 12/31/2007
Posts: 23

Hi,

Changed to RecvBufferEx, but still the same error.
Also made no difference with the zlib turned off.

Thanks,

Tony
#4628
Posted: 01/03/2008 11:34:39
by Tony Caduto (Basic support level)
Joined: 12/31/2007
Posts: 23

I captured the first read in a string and it's getting it all, then right after that a exception is raised. Some of the data received from putty looks like it's compressed in the string. I have compression turned off on putty though. The snapshot of putty is very new, from Dec 20th 2006.

I can connect to the c# demo server with that version of putty though.

Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages

Reply

Statistics

Topic viewed 7187 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!