OpenSSH library

Nicolas.Williams at Nicolas.Williams at
Tue May 21 00:19:57 EST 2002

The OpenSSH code is far from usable as a library. Throughout the OpenSSH code you'll find the use of globals and static globals and calls to fatal() (which is a fancy wrapper around exit()) and so on, to say nothing of the fact that OpenSSH has its own event loop and, if you want to use OpenSSH as a library, you have to either fit the app into that loop or abstract the loop so the library could fit into the app's event loop - or use multiple threads (but OpenSSH code is not thread-safe currently).

So no, you can't make a useful library out of OpenSSH as it stands.

A lot of the major issues that prevent OpenSSH from being made into a library could be fixed with some work. Stuff the globals into a context structure, make sure it gets passed around... give the app a way to register its own exit() and select() functions for use by the library (the app-provided exit() might just longjmp()), provide an I/O abstraction so the app can read/write from/to SSH channels, etc... Actually, that's a bit more than "some work"...

But I kinda doubt that libopenssh is a goal or a high-priority goal for the OpenSSH folk. In the meantime you can use ssh w/ pipes and/or port forwarding to achieve mostly the same effect, though with more context switching and data copying.



Visit our website at

This message contains confidential information and is intended only 
for the individual named.  If you are not the named addressee you 
should not disseminate, distribute or copy this e-mail.  Please 
notify the sender immediately by e-mail if you have received this 
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free 
as information could be intercepted, corrupted, lost, destroyed, 
arrive late or incomplete, or contain viruses.  The sender therefore 
does not accept liability for any errors or omissions in the contents 
of this message which arise as a result of e-mail transmission.  If 
verification is required please request a hard-copy version.  This 
message is provided for informational purposes and should not be 
construed as a solicitation or offer to buy or sell any securities or 
related financial instruments.

More information about the openssh-unix-dev mailing list