pyscripter 689 Posted July 11, 2020 (edited) Ssh-Pascal is a new free and open source library providing ssh support to Delphi, based on libssh2. Libssh2 is a mature ssh library used by PHP (built-in), Rust and many other languages and applications. Features: Extensive ssh features Support for different authorization methods (publickey, password, agent, hostbased and keyboard-interactive) Known host management. Execution of commands on the host capturing stdout and stderr Comprehensive sftp support Port forwarding (currently only local to remote) scp support High-level pascal-friendly, interface-based wrapping of ssh functionality. Lower-level usage is possible. Edited July 11, 2020 by pyscripter 3 2 Share this post Link to post
pyscripter 689 Posted July 11, 2020 Help wanted: libssh2 can be compiled so that it uses Windows CNG instead of OpenSSL, thus avoiding any dependence on other dynamic libraries. I wonder whether it would be possible to compile it into C obj files that can be linked into the Delphi executable. This would simplify the deployment greatly. Any help on this would be greatly appreciated. 1 Share this post Link to post
Edwin Yip 154 Posted July 12, 2020 Well done! This project makes me existing :) Just recently I needed to implement a SFTP feature, I first tried the only two existing libssh2 wrapper for Delphi, they both are kinda out of dated, one of them is the one your project page points to. Both failed to pass my initial tests against SFTP servers on both Windows and Linux. I then resorted to https://www.syncovery.com/tgputtylib/ and it worked like a charm. Just my two cents. If possible, would love to hear about your options on all the already available options and your decisions behind developing this new, promising wrapper! Share this post Link to post
Edwin Yip 154 Posted July 12, 2020 I guess @David Heffernan or @Remy Lebeau might can help you on your question described above :) Share this post Link to post
pyscripter 689 Posted July 12, 2020 7 minutes ago, Edwin Yip said: to hear about your options I guess you mean opinions 😀. I was not aware of tgputtylib, but it is commercial and only covers sftp. The other options had reasonable sftp functionality (however no handling of ~ in paths) but were based on old versions of libssh2 had numerous C to Delphi translation issues especially related to 64bits that needed fixing did not provide for remote execution of commands and port forwarding which was important to me and fundamental part of ssh. Share this post Link to post
Edwin Yip 154 Posted July 12, 2020 (edited) 9 hours ago, pyscripter said: I guess you mean opinions 😀. I was not aware of tgputtylib, but it is commercial and only covers sftp. Yes, I meant opinions :D And thanks for sharing them, I now have a clearer understanding of your great project! However, TGPuttyLib is open source: https://github.com/superflexible/TGPuttyLib And yes, it currently supports only sftp. On the other hand, I guess it's quite easy to also add SSH functions because the header's already translated, just Delphi classes were lacking. The author used to say he has a plan for it. Edited July 12, 2020 by Edwin Yip Share this post Link to post
Guest Posted July 12, 2020 10 hours ago, pyscripter said: Help wanted: I am sorry that my help here is just pointing few things, but that might help you or anyone want to do it 1) libssh2 from the documentation can be compiled with one of Quote OpenSSL Libgcrypt WinCNG mbedTLS i would pick mbedTLS any time, compiling it from visual studio is piece of cake, also if libssh2 internally will use it for crypto then the size will be so much smaller, we are talking about something less than 500kb for full mbedTLS, i know it is slower than OpenSSL in some places, but not sure it will be slower for just CSPRNG. 2) Something always annoyed me, why no one did link the obj's files in to one with zLib !, you can link multiple obj files into one with ld -relocatable .\ReleaseDLL\SomeDir\*.obj -o OneObj.o this can take almost 99% of the time needed to add/link object files to Delphi and find external dependencies, removing the need to deal with the order of those files, and their circular dependency if there is any. 3) is the case is to only build libssh2 without OpenSSL, or libssh2 be linked as object files directly into Delphi not using DLL ?, i tried to open the VS solution (libssh2.dsw) and it was reported as corrupted project, there might be a chance to make this work. Hope that help. Share this post Link to post
pyscripter 689 Posted July 12, 2020 5 hours ago, Edwin Yip said: I guess it's quite easy to also add SSH functions because the header's already translated Putty splits the ssh functionality into different executables. ssh is provided by plink.exe. The project converted to a dll only psfpt.exe. 1 Share this post Link to post
Edwin Yip 154 Posted July 12, 2020 (edited) 55 minutes ago, pyscripter said: Putty splits the ssh functionality into different executables. ssh is provided by plink.exe. The project converted to a dll only psfpt.exe. Oh sorry, I guess I'm wrong on this part - there is no header translation for SSH yet. It's just that the author has stated that "SSH shell and SCP features will probably be added in a future version." That being said, I'm very interested in the SSH feature provided by your library! Edited July 12, 2020 by Edwin Yip Share this post Link to post
pyscripter 689 Posted July 14, 2020 (edited) On 7/12/2020 at 9:53 AM, Kas Ob. said: is the case is to only build libssh2 without OpenSSL, or libssh2 be linked as object files directly into Delphi not using DLL Thanks for the info. I would like to link the object files into Delphi avoiding the need to deploy DLLs. It would be great if you were able to do this. This link shows how to use cmake to compile the dll with Visual Studio. The project also supports nmake. @Vincent ParrettYou appear to be the original author of System.RegularExpressions. How did you compile the C code of PCRE avoiding the need to bring in c runtime dependencies. Edited July 14, 2020 by pyscripter Share this post Link to post
Vincent Parrett 750 Posted July 14, 2020 @pyscripter I didn't, I leveraged the work done by Jan Goyvaerts in TPerlRegex (System.RegularExpressionCore) which leveraged the work of others on PCRE imports (System.RegularExpressionsAPI) Share this post Link to post
Edwin Yip 154 Posted July 14, 2020 3 hours ago, pyscripter said: @Vincent ParrettYou appear to be the original author of System.RegularExpressions. How did you compile the C code of PCRE avoiding the need to bring in c runtime dependencies. I guess @Arnaud Bouchez might can shed some light on it, because I know mORMot involves a lot of work in that regard. Share this post Link to post
Guest Posted July 14, 2020 Here compiled libssh2 DLL's for WindowsCNG libssh2_WinCNG32.zip libssh2_WinCNG64.zip and here what i was talking about linking many object into one libssh2_Obj32.zip libssh2_Obj64.zip But my objects files are build without the right DLL's imports, so the objects files here just for showing how it can be done and not to be waste time with, someone more qualified with more experience can build those objects with the right imports minimizing the functions needed to be included in Delphi project to something around 20, ( sprintf, memmove....) instead of many API calls like CloseHandle and SendMessage ..etc , about those too i don't think the agent.c is needed but i might be wrong here, the agent functions are not used internally and there for external usage. ld 64bit version from MinGW didn't work with wildcards !, so i had to use dir in cmd to copy the object files list instead of writing them one by one. Quote ld.exe -relocatable agent.obj bcrypt_pbkdf.obj blowfish.obj channel.obj comp.obj crypt.obj global.obj hostkey.obj keepalive.obj kex.obj knownhost.obj mac.obj misc.obj packet.obj pem.obj publickey.obj scp.obj session.obj sftp.obj transport.obj userauth.obj version.obj -o WinCNG_64.o @pyscripter Please test them as i don't have full functionality test not even small one, both try to connect and load fine, so might be fine . About mbedTLS it does compile fine and generate binaries (obj,lib..), just like libssh2, both compile easily with no problem, but my VS is broken and can't fix directories for some reason after wasting an hour just trying to satisfy VS with lib requirements and failed, again someone with better experience with VS can do it easily, the idea of reinstalling VS from scratch is killing me already. Share this post Link to post
Guest Posted July 14, 2020 Irrelevant question just hit me : Compiling an open source code without changing any thing in the source, but only removing one include in the build process, like agent.c from the VS solution, does this violate (a/the) license ? NOTE: I didn't do that with the above compiled files and the agent is compiled fine there, i was tracking the API usage and found this agent making many might be unneeded calls. Share this post Link to post
Guest Posted July 14, 2020 @pyscripter As fast and easy workaround to remove the external/additional DLL's, you can use https://github.com/DSPlayer/memorymodule and add the DLL as resource, i have been using this for few years and it works like a charm on both 32bit and 64bit, but you need to redeclare the imported functions to be dynamically loaded at runtime. Share this post Link to post
Fr0sT.Brutal 900 Posted July 24, 2020 On 7/14/2020 at 4:30 PM, Kas Ob. said: @pyscripter As fast and easy workaround to remove the external/additional DLL's, you can use https://github.com/DSPlayer/memorymodule and add the DLL as resource, i have been using this for few years and it works like a charm on both 32bit and 64bit, but you need to redeclare the imported functions to be dynamically loaded at runtime. This repo is very outdated. I forked and did lots of updates from original C project but this tech has disadvantages: - antiviruses are likely be nervous when your app would use such memory loading - there's no workaround if a library is doing something important in DLLMain Share this post Link to post
Guest Posted July 24, 2020 (edited) 45 minutes ago, Fr0sT.Brutal said: I forked and did lots of updates from original C project Is it public ? Where ? Found it. 45 minutes ago, Fr0sT.Brutal said: antiviruses They always have the red eyes around Delphi applications. Edited July 24, 2020 by Guest Share this post Link to post