Subject: Re: SFTP and libssh

Re: SFTP and libssh

From: Paul Romero <paulr_at_rcom-software.com>
Date: Sat, 10 Jul 2010 14:22:47 -0700

Peter Stuge wrote:

> Paul Romero wrote:
> > I looked at the examples and they are quite good. Also,
> > I performed some experiments and concluded libssh2
> > is well suited to my application.
>
> Great!
>
> > I suppose the size of the library can be reduced by
> > disabling libz compression.
>
> I actually doubt that, since zlib is an external dependency. The code
> in libssh2 that would call into zlib is very small, so the space
> saving in libssh2 would be minimal. But if no other package in your
> target system depends on zlib then you can obviously save the space
> needed for that, by disabling compression.
>
> > I noticed PIC in the configuration options. What is it and is it
> > important ?
>
> Short for Position Independent Code, and yes, all shared libraries
> must be compiled PIC or the machine code will make assumptions on
> which address in memory they will be running at, which can usually
> not be predicted at build time.
>
> > Finally, any hints about how to minimize the library size would be
> > appreciated.
>
> I'm sure you can get size down by removing everything from the
> library that is not absolutely neccessary. If you do a good job at
> that and come up with a clean patch against the current master
> codebase which introduces some configure options for the minimal
> behavior I would welcome that contribution into the official code.
>
> Another option is of course for you to locally maintain a more brutal
> modification of the code where you simply rip out things that you
> know you will never use. Then you'll have to do more work to re-do
> those changes if at some point you wish to use a newer version of
> libssh2.
>
> I just ran strip on the plain Linux objects built here:
>
> /tmp/.libs $ ls -l
> total 456
> -rw-r--r-- 1 stuge stuge 3460 Jul 10 22:36 agent.o
> -rw-r--r-- 1 stuge stuge 16512 Jul 10 22:36 channel.o
> -rw-r--r-- 1 stuge stuge 2820 Jul 10 22:36 comp.o
> -rw-r--r-- 1 stuge stuge 2396 Jul 10 22:36 crypt.o
> -rw-r--r-- 1 stuge stuge 812 Jul 10 22:36 global.o
> -rw-r--r-- 1 stuge stuge 2988 Jul 10 22:36 hostkey.o
> -rw-r--r-- 1 stuge stuge 1084 Jul 10 22:36 keepalive.o
> -rw-r--r-- 1 stuge stuge 15216 Jul 10 22:36 kex.o
> -rw-r--r-- 1 stuge stuge 7988 Jul 10 22:36 knownhost.o
> -rw-r--r-- 1 stuge stuge 432 Jul 10 22:36 libgcrypt.o
> -rw-r--r-- 1 stuge stuge 123148 Jul 10 22:36 libssh2.a
> -rw-r--r-- 1 stuge stuge 2817 May 3 15:26 libssh2.exp
> lrwxrwxrwx 1 stuge stuge 13 Jul 10 22:33 libssh2.la -> ../libssh2.la
> -rw-r--r-- 1 stuge stuge 938 May 3 15:26 libssh2.lai
> lrwxrwxrwx 1 stuge stuge 16 Jul 10 22:33 libssh2.so -> libssh2.so.1.0.1
> lrwxrwxrwx 1 stuge stuge 16 Jul 10 22:33 libssh2.so.1 -> libssh2.so.1.0.1
> -rwxr-xr-x 1 stuge stuge 134128 Jul 10 22:36 libssh2.so.1.0.1
> -rw-r--r-- 1 stuge stuge 2953 May 3 15:26 libssh2.ver
> -rw-r--r-- 1 stuge stuge 2080 Jul 10 22:36 mac.o
> -rw-r--r-- 1 stuge stuge 3056 Jul 10 22:36 misc.o
> -rw-r--r-- 1 stuge stuge 3572 Jul 10 22:36 openssl.o
> -rw-r--r-- 1 stuge stuge 7696 Jul 10 22:36 packet.o
> -rw-r--r-- 1 stuge stuge 432 Jul 10 22:36 pem.o
> -rw-r--r-- 1 stuge stuge 8352 Jul 10 22:36 publickey.o
> -rw-r--r-- 1 stuge stuge 7996 Jul 10 22:36 scp.o
> -rw-r--r-- 1 stuge stuge 8032 Jul 10 22:36 session.o
> -rw-r--r-- 1 stuge stuge 18408 Jul 10 22:36 sftp.o
> -rw-r--r-- 1 stuge stuge 4272 Jul 10 22:36 transport.o
> -rw-r--r-- 1 stuge stuge 13284 Jul 10 22:36 userauth.o
> -rw-r--r-- 1 stuge stuge 664 Jul 10 22:36 version.o
>
> The largest offenders are SFTP, channel and userauth, all of which
> you need. I guess you can strip userauth down selectively. Maybe you
> can remove stuff like knownhost.o and scp.o and save a few kb..

I suppose the same applies to the agent code if your system is not or
can not run an agent. Basically, I think you can comment everything
out it the following files: ssh2_agent.c and agent.c.

>
>
> But I have to say that if the system is so size constrained that you
> need to hunt kilobytes then you will face severe problems quite soon
> anyway, so in that case I'd work on increasing storage as soon as
> possible instead.
>
> //Peter
> _______________________________________________
> libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

--
Paul Romero
RCOM Communications Software
Phone/Fax: (510)339-2628
E-Mail: paulr_at_rcom-software.com
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-07-10