An SFTP client shared library (dll/so/dylib) with bindings and classes for C++, Delphi and Free Pascal based on PuTTY

Overview

TGPuttyLib

A shared library / DLL with Delphi and C++ bindings based on PuTTY, for Windows, macOS, and Linux.

The new TGPuttyLib SFTP Library is a DLL/.so/.dylib conversion of the psftp program from the well-known PuTTY suite by Simon Tatham.

It allows developers to transfer files with the highest possible transfer rates (over 100MB/sec). The rates are higher than with any other known library.

TGPuttyLib is based on PuTTY Release 0.74. Ready-to-use classes are currently available for C++, Delphi and Free Pascal.

The library is now available for Windows, macOS and Linux.

The compiled libraries can be found in the Win32/Win64/Linux (Compiled Libs)/macOS (Compiled Libs) folders. There is no difference between a Debug and Release version.

Compiled demos can be found in the Releases section, and on the project web site.

For more information, please visit the project web site: https://www.syncovery.com/tgputtylib


DIRECTORIES AND FILES

tgputtylib.pas - Delphi Unit interfacing with the DLL

tgputtysftp.pas - Delphi SFTP Client Class (recommended, but uses 8-bit strings)

tgputtysftpclient.pas - Delphi SFTP Client Component (not needed, see note at the end of this document)

ctgputtylib.cpp,h - C++ DLL bindings

tgputtylibcbclass.cpp,h - C++ Builder SFTP Client Class (using 8-bit strings)

tgputtycbsftpclient.cpp,h - C++ Builder Component (using UnicodeStrings)

tgputtylibvcclass.cpp,h - Visual C++ SFTP Client Class (using 8-bit strings)


TGPuttyLib.dpk etc. - Delphi Package for SFTP Client Component

TGPuttyLibCPP.cbproj etc. - C++ Builder Package for SFTP Client Component


DelphiSimpleDemos - Delphi Command Line Demos

DelphiVCLComponentDemo - Fully working SFTP client application using the SFTP Client Component

DelphiVCLDemo - Fully working SFTP client application using the SFTP Client Class

FPCSimpleDemos - FPC Command Line Demos

CPPDemos - C++ Demos


tgputtylib - DLL source code based on PuTTY


bpl - compiled Delphi Package for XE 10.3

Win32, Win64 - compiled binaries for Windows

Linux (Compiled Libs) - compiled binaries for Linux (various CPU types)

macOS (Compiled Libs) - compiled binaries for macOS (Intel 32 and 64 bits)


DELPHI RECOMMENDATION

Please consider just using the TTGPuttySFTP class in tgputtysftp.pas rather than the TTGPuttySFTPClient component in tgputtysftpclient.pas. Just include the folder with thePascal source files in your compiler path.

The class has many advantages! You don't have to install anything into the IDE. Much easier when you switch to a newer Delphi version in the future.

You can just create the class and assign properties in Delphi code, rather than using the component.

Take a look at the DelphiVCLDemo example, rather than DelphiVCLComponentDemo.

Note that the TTGPuttySFTP class uses AnsiStrings, so you need to work with Utf8Encode and Utf8Decode or Utf8ToString.

The component, on the other hand, uses UnicodeStrings.

Comments
  • Error running FPCSFTPClassTest on Raspberry Pi FreePascal

    Error running FPCSFTPClassTest on Raspberry Pi FreePascal

    Hello guys. Program compiled with Lazarus / FreePascal under Linux tested on a Raspberry Pi. This error message appears even though the libtgputty.so library is included in the same directory.

    Regards, Olaf

    [email protected]:~ $ /home/pi/SFTP/FPCSimpleDemos/fpcsftpclasstest TGPuttyLib not available: /home/pi/SFTP/FPCSimpleDemos/libtgputty.so: cannot open shared object file: No such file or directory Testing is done ... press ENTER.

    [email protected]:~ $

    opened by Oli1L 14
  • How to get file list with separate attributes?

    How to get file list with separate attributes?

    How to get a list of files in a directory with their names, timestamps, filesizes etc as individual fields? Doing the "ls" outputs to the console the list but I can't access the string of the output nor do I see how I can get a list of files like in a to access them? I'm using C++ (with GCC under Linux and VisualStudio under Windows) and saw that these class-files are different per compiler vendor but both incomplete with regards to the C interface:

    • tgputtylibcbclass
    • tgputtylibvcclass
    opened by patlecat 13
  • server umask not applied when uploading files

    server umask not applied when uploading files

    When I transfer files, they seem to have random permissions, e.g.:

    [email protected]:~$ ls -la README.md 
    ---------- 1 user user 2053 Dez  3 09:28 README.md
    

    Server umask is 0002. I observed other (sometimes quite strange) permissions as well. As a workaround, I read the stats of the target directory and assign the permissions to the transferred file. It seems to be quite awkward to having to do it this way:

    sftp.GetStat('.', Attrs);
    sftp.UploadFile(MyFile, False);
    sftp.GetStat(MyFile, AttrsUpload);
    AttrsUpload.permissions := Attrs.permissions;
    sftp.SetStat(MyFile, AttrsUpload);
    

    Is there a better way to achieve proper permissions of the uploaded files?

    opened by rosch100 10
  • Compiler error under Xe4, but I'll fix it some time later when I started using it if you don't :)

    Compiler error under Xe4, but I'll fix it some time later when I started using it if you don't :)

    Get this error when compiling it with XE$ for the first time: [dcc32 Error] tgputtysftp.pas(494): E2034 Too many actual parameters at: attrs.mtime:=DateTimeToUnix(ATimestamp,isUTC);

    I guess it's just a very small issue and I'll fix it when I started using it some time later if you don't , but just report it here first :)

    Happy holidays :)

    opened by edwinyzh 5
  • VCL demo code runs, component and my code blow up

    VCL demo code runs, component and my code blow up

    I'm running D10.2 and copied the file tree to a folder, built the libs and component and installed the component.

    I tried to open the VCL component demo and it gave a weird "External Exception C06D007E" while opening the form, and didn't load the component properly.

    So I opened the VCL non-component demo and it builds and runs just fine.

    I copied the code to init everything from this running app into my app. It compiles fine, but it blows up when it get to initializing the DLL. Same error as the component (different address).

    I don't work with DLLs very much, and this just seems to be throwing an unhandled exception. I'm not sure what to do to make it work, or why the one demo would work fine and my code that's doing the exact same stuff would blow up.

    Is there supposed to be a delay in opening the DLL so it can get the OnVerifyHostKey callback configured? Because it's blowing up on the initial Create with no opportunity to set the callback.

    It's blowing up here:

    constructor TTGPuttySFTP.Create(const verbose:Boolean);
    var puttyversion:Double;
        tgputtylibbuild:Integer;
    begin
      tgputtygetversions(@puttyversion,@tgputtylibbuild);    <<-----------------
    
    opened by thetoolwiz 4
  • First impression - well done!

    First impression - well done!

    So I started evaluating and choosing a sFTP client.

    I'm testing it against a FreeSSHd SFTP server on local Windows, and an OpenSSH server also on Windows.

    • I first tried https://github.com/pult/libssh2_delphi, it can connect to OpenSSH, and failed to connect to FreeSSHd (returns some thing like 'waiting for password response' which I couldn't figure out how to fix).

    • Then I tried SecureBridge (not the latest version, I don't have it. It's an old version released about 2 years ago). It failed to connect to the local FreeSSHd server (I foroget the error message), so I stopped testing it further.

    • At last I tested TGputtyLib, and it can connect to both of the servers! I'm testing it further now...

    opened by edwinyzh 4
  • Connect to SFTP server with private key

    Connect to SFTP server with private key

    Hi, there is any way to connect to a SFTP server with a private key(without using a password)?. I only have a ppk file and i don't have the password.

    opened by aleixmascaro 4
  • Build13 GUI with build16 lib can't connect to server

    Build13 GUI with build16 lib can't connect to server

    When I use the latest Windows (under Windows10) GUI app (Build13) and replace the lib with the latest binary (Build16) then I receive the following error each time, while I can connect to that ftp server fine with CyberDuck. It gave the same error using lib version Build13 btw. This is the log:

    Library version: tgputtylib build 16 based on PuTTY Release 0.76
    Connecting with u123456.your-storagebox.de, port 21, as user u123456.
    psftp_connect connecting with u123456.your-storagebox.de, port 21, as user u123456.
    Looking up host "u123456.your-storagebox.de" for SSH connection
    Connecting to 2a02:4f9:b17:1000::67 port 21
    We claim version: SSH-2.0-tgputtylib_Release_0.76
    Connected to 2a02:4f9:b17:1000::67
    Remote side unexpectedly closed network connection
    FATAL ERROR: Remote side unexpectedly closed network connection
    psftp_connect result is 1
    tgsftp_connect final result is 1
    
    opened by patlecat 3
  • Where to find the meanings of the error codes?

    Where to find the meanings of the error codes?

    Hello Tobias,

    When I get errors like:

    TGPuttySFTPException: tgsftp_cd: Error 5, bad message

    Where I can find a list of such errors along with the explanations of the errors?

    PS, from the log of the FreeSSHd the error is that the directory the client want to change to doesn't exist.

    Thanks!

    opened by edwinyzh 3
  • May I ask the motivation of this project?

    May I ask the motivation of this project?

    This is definitely a useful project! Just out of curiosity - why don't use libssh directly? From the homepage I read that the advantage of TGPuttyLib is faster transfer speed?

    I've no experience with libssh nor TGPuttyLib yet, but will need to implement sFTP transfer function in the near future, so will be happy to hear about how do you think. Because I guess using libssh needs less work if libssh satisfied you at the very beginning.

    And happy holidays!

    opened by edwinyzh 3
  • Consider moving the the EXE files to a branch?

    Consider moving the the EXE files to a branch?

    From time to time, updating local repository fails no matter it's TortoiseSVN or GitExtension, using direction connection or going through Socks5 proxy. I guess it maybe because there a quite amount of the big EXE files in the repo.

    Would you consider separate those DEMO EXEs out of the source repository?

    Thanks for your consideration.

    opened by edwinyzh 3
  • Using gputtylib.pas and gputtysftp.pas in RADStudio C++ project

    Using gputtylib.pas and gputtysftp.pas in RADStudio C++ project

    Hi, thanks for the great software. I'm trying to add gputtylib.pas and gputtysftp.pas to a C++ Builder project. I can usually mix PAS and CPP with no problem, but I am getting an unresolved external for each procedure in gputtylib.pas that declared to be in the DLL. here's an example.

    procedure tggetstructsizes(const Pulongsize,Pnamesize,Pattrsize,Pnamessize:PInteger); cdecl; external tgputtydll {$ifdef HASDELAYED}delayed{$endif};

    I can use the PAS files in a Delphi program with no problem. Any ideas what I can do to keep the linker in C++Builder happy.

    As an aside, I have made a C++ project using the C++ specific files, but it crashes when downloading a file from an SFTP server. This is why I'd like to use the PAS files, as they work perfectly in a Delphi app.

    opened by XenoGallois 2
  • Example using Unicode strings and real C++ code?

    Example using Unicode strings and real C++ code?

    It would be helpful to have an example of a generic C++ use of strings with STL that can run under Windows and Linux. The examples now are very specific to compiler vendors only, I don't see this as an advantage, especially for a C++ user. Also I find the mislabelling of C code as "C++" not appropriate.

    opened by patlecat 3
  • No progress when uploading througth SFTP

    No progress when uploading througth SFTP

    The progress information during download (OnProgress event) is driven due to

    if Assigned(TGPSFTP.OnProgress) then
     TGPSFTP.OnProgress(Offset+bufsize,false);
    

    In write_to_stream(), is there a reason the same code is not in read_from_stream() to give equal progress during upload? Like this:

    function read_from_stream(const offset:UInt64;const buffer:Pointer;const bufsize:Integer;const libctx:PTGLibraryContext):Integer; cdecl;
    var TGPSFTP:TTGPuttySFTP;
    begin
      TGPSFTP:=TTGPuttySFTP(libctx.Tag);
      if Assigned(TGPSFTP.FUploadStream) then begin
         TGPSFTP.FUploadStream.Position:=Offset;
         Result:=TGPSFTP.FUploadStream.Read(buffer^,bufsize);
         if Assigned(TGPSFTP.OnProgress) then
            TGPSFTP.OnProgress(Offset+bufsize,false);
         end
      else
         Result:=0;
      end;
    
    opened by mebo 4
Releases(19)
Owner
Tobias Giesen
Developer of Syncovery, the super flexible back-up and sync tool.
Tobias Giesen
Rudimentary opinionated client-side lua libwayland bindings and scanner

wau This should work with Lua 5.3+. By default it builds with 5.3 instead of 5.4 because the examples depend on lgi. These aren't 1-to-1 bindings to l

null 4 Nov 19, 2022
SimpleSockets is a lightweight set of classes that allow developers to implement IP based network programs.

------------------------------------------------------------------------------------------ * History -------------------------------------------------

DFHack 143 Dec 8, 2022
Triton Python and C++ client libraries and example, and client examples for go, java and scala.

Triton Client Libraries and Examples To simplify communication with Triton, the Triton project provides several client libraries and examples of how t

Triton Inference Server 228 Jan 5, 2023
Webdav-client-cpp - C++ WebDAV Client provides easy and convenient to work with WebDAV-servers.

WebDAV Client Package WebDAV Client provides easy and convenient to work with WebDAV-servers: Yandex.Disk Dropbox Google Drive Box 4shared ownCloud ..

Cloud Polis 103 Jan 1, 2023
VEngine-Client - vEngine: Official Client Module

━ S Y N O P S I S ━ Maintainer(s): Aviril, Tron vEngine is Next-Gen Sandbox-Engine being crafted in C++. In contrast to UE/Unity/ReverseEngineered-Mod

ᴠ : ꜱᴛᴜᴅɪᴏ 15 Sep 7, 2022
Pyth-client - client API for on-chain pyth programs

pyth-client client API for on-chain pyth programs Build Instructions # depends on openssl apt install libssl-dev # depends on libz apt install zlib1g

Pyth Network 115 Dec 16, 2022
This repository provides a C++ client SDK for Unleash that meets the Unleash Client Specifications.

Unleash Client SDK for C++ This repository provides a C++ client SDK for Unleash that meets the Unleash Client Specifications. Features The below tabl

Antonio Ruiz 4 Jan 30, 2022
A DLL that serves OutputDebugString content over a TCP connection

RemoteDebugView A DLL that serves OutputDebugString content over a TCP connection Usage You will need to compile the DLL and then call the exported fu

hotnops 33 Nov 29, 2022
A Lightweight and fully asynchronous WebSocket client library based on libev

libuwsc(中文) A Lightweight and fully asynchronous WebSocket client library based on libev for Embedded Linux. And provide Lua-binding. Why should I cho

Jianhui Zhao 285 Dec 24, 2022
ChakraCore bindings for aardio

ChakraCore-bindings-for-aardio ChakraCore is a Javascript engine with a C API you can use to add support for Javascript to any C or C compatible proje

null 9 Feb 18, 2022
HP-Socket bindings for aardio

HP-Socket-bindings-for-aardio HP-Socket is a high performance network framework. aardio is an extremely easy-to-use dynamic language, but it is also a

null 9 Jan 3, 2022
Python bindings for open source MuJoCo

pymujoco Python bindings for open source MuJoCo using pybind11. from pymujoco import * r = mjv_create_renderer() #help(p) m = mj_loadXML("humanoid.xm

null 35 Aug 20, 2022
Rust bindings for Pixar's Universal Scene Description (USD)

Getting started Make sure you have cppmm built/working. https://github.com/vfx-rs/cppmm Build usd 21.11 Then run bash bind.sh. You need to make sure a

null 36 Dec 9, 2022
The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.

Welcome! The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design

Microsoft 7.2k Dec 30, 2022
A GlobalProtect VPN client (GUI) for Linux based on OpenConnect and built with Qt5, supports SAML auth mode.

A GlobalProtect VPN client (GUI) for Linux based on OpenConnect and built with Qt5, supports SAML auth mode.

Kevin Yue 603 Jan 2, 2023
Jellyfin Desktop Client based on Plex Media Player

Jellyfin Media Player Based on (but not affiliated with) Plex Media Player. Please see: Corresponding web client: Repo Release API Docs in client-api.

Ian Walton 1.3k Dec 27, 2022
Qt Based WhatsApp Client

WhatSie WhatSie is Light, feature rich WhatsApp web client written in Qt and not on Electron. A simple & beautiful desktop client for WhatsApp Web. Ch

Keshav Bhatt 691 Dec 27, 2022
A VPN client for Android based on OpenVPN made with Jetpack Compose.

Gear VPN - Free, Secure & Open sourced VPN Tech Stack Jetpack Compose - Google's new UI toolkit for developing native Android apps. Navigator-Compose

Kaustubh Patange 86 Dec 23, 2022
Simple WHIP Client (based on GStreamer's webrtcbin)

Simple WHIP Client This is an attempt to create a simple prototype of a WHIP client, to be used mostly for testing with my Simple WHIP Server (based o

Lorenzo Miniero 34 Nov 18, 2022